Crates.io | alloc-tls |
lib.rs | alloc-tls |
version | 0.2.0 |
source | src |
created_at | 2017-11-16 08:22:37.445112 |
updated_at | 2020-04-04 00:00:50.157448 |
description | Thread-local storage that is safe for use in implementing global allocators. |
homepage | |
repository | https://github.com/ezrosent/allocators-rs/tree/master/alloc-tls |
max_upload_size | |
id | 39534 |
size | 23,630 |
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:
#[thread_local]
attribute, registering
destructors for types that implement Drop
requires 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.alloc_thread_local!
can detect whether the library has been loaded or not,
and can avoid using TLS if malloc
or other similar calls are made from the
loader itself during loading.Known limitations:
alloc-tls
does not currently support platforms that do not support the
#[thread_local]
attribute.