Crate thread_safe[][src]

Expand description

Let’s say you have some thread-unsafe data. For whatever reason, it can’t be used outside of the thread it originated in. This thread-unsafe data is a component of a larger data struct that does need to be sent around between other threads.

The ThreadSafe contains data that can only be utilized in the thread it was created in. When a reference is attempted to be acquired to the interior data, it checks for the current thread it comes from.

ThreadKey

The ThreadKey is a wrapper around ThreadId, but !Send. This allows one to certify that the current thread has the given ThreadId, without having to go through thread::current().id().

Structs

NotInOriginThread

Error type for “we are not in the current thread”.

ThreadKey

A ThreadId that is guaranteed to refer to the current thread, since this is !Send.

ThreadSafe

The whole point.