You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Core Foundation is sufficiently thread-safe that, if you program with care, you should not run into any problems related to competing threads. It is thread-safe in the common cases, such as when you query, retain, release, and pass around immutable objects. Even central shared objects that might be queried from more than one thread are reliably thread-safe.
Like Cocoa, Core Foundation is not thread-safe when it comes to mutations to objects or their contents. (...)
The C __CFRunLoop type also looks like it has a mutex around mutation operations (example), so it looks a lot like this should be safe to pass between threads... and you'd need to do this anyway if you want to schedule work on another thread.
Very few types in this crate (currently four) are marked as Send or Sync; and there's probably other types that could be marked that way too. Apple's documentation seems to suggest that Core Foundation types could be non-thread-safe (just you should assume safe unless otherwise stated), so I don't think that implementing Send + Sync for T: TCFType is wise.
The text was updated successfully, but these errors were encountered:
The core-foundation-rs
CFRunLoop
type does not appear to be marked asSend
orSync
, and I suspect they should be.Apple's Core Foundation docs appear to suggest those types are generally thread-safe (emphasis mine):
Looking at another usage,
mozilla/authenticator-rs
passes aCFRunLoop
between threads in aSendableRunLoop
type: it schedules aCFRunLoopObserver
in a new thread, which then sends back the currentCFRunLooop
over ampsc::channel
and picks it up from the current thread.The C
__CFRunLoop
type also looks like it has a mutex around mutation operations (example), so it looks a lot like this should be safe to pass between threads... and you'd need to do this anyway if you want to schedule work on another thread.Very few types in this crate (currently four) are marked as
Send
orSync
; and there's probably other types that could be marked that way too. Apple's documentation seems to suggest that Core Foundation types could be non-thread-safe (just you should assume safe unless otherwise stated), so I don't think that implementingSend + Sync
forT: TCFType
is wise.The text was updated successfully, but these errors were encountered: