Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Module as Send #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Mark Module as Send #3

wants to merge 1 commit into from

Conversation

cspiegel
Copy link

@cspiegel cspiegel commented Jun 2, 2021

Because it includes the raw pointer *mut openmpt_sys::openmpt_module, Module is not automatically Send. However, as far as I can tell, it's valid for it to implement Send. According to the C API docs:

  • libopenmpt is thread-aware.
  • Individual libopenmpt objects are not thread-safe.
  • libopenmpt itself does not spawn any user-visible threads but may spawn threads for internal use.
  • You must ensure to only ever access a particular libopenmpt object from a single thread at a time.
  • Consecutive accesses can happen from different threads.
  • Different objects can be accessed concurrently from different threads.

So it's safe to send OpenMPT pointers to different threads, as long as access is guarded, e.g. with a mutex. So Sync wouldn't be good, but Send is just fine, and will allow Module to be wrapped in a mutex.

@mcb2003 mcb2003 mentioned this pull request May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant