alloc-tls

Crates.ioalloc-tls
lib.rsalloc-tls
version0.2.0
sourcesrc
created_at2017-11-16 08:22:37.445112
updated_at2020-04-04 00:00:50.157448
descriptionThread-local storage that is safe for use in implementing global allocators.
homepage
repositoryhttps://github.com/ezrosent/allocators-rs/tree/master/alloc-tls
max_upload_size
id39534
size23,630
Joshua Liebow-Feeser (joshlf)

documentation

https://docs.rs/alloc-tls

README

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 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.
  • 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 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.
Commit count: 0

cargo fmt