alloc-tls-0.2.0 doesn't have any documentation.
alloc-tls
alloc-tls provides the alloc_thread_local! macro, a near-drop-in replacement
for the standard library's thread_local! macro that is safe for use in
implementing a global allocator.
Unlike thread_local!, alloc_thread_local! address the following issues
unique to implementing a global allocator:
- On platforms that support the
#[thread_local]attribute, registering destructors for types that implementDroprequires allocation. When a thread-local is initialized from a call to an allocation function (malloc,free, etc), this causes reentrancy.alloc_thread_local!can detect this. - On Mac, it is not safe to access TLS while a dynamic library is being loaded.
When implementing a Mac dynamic library that provides a global allocator,
alloc_thread_local!can detect whether the library has been loaded or not, and can avoid using TLS ifmallocor other similar calls are made from the loader itself during loading.
Known limitations:
alloc-tlsdoes not currently support platforms that do not support the#[thread_local]attribute.