Skip to content

Mark Module as Send#3

Open
cspiegel wants to merge 1 commit intosm-Fifteen:masterfrom
cspiegel:send
Open

Mark Module as Send#3
cspiegel wants to merge 1 commit intosm-Fifteen:masterfrom
cspiegel:send

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