MCPcopy Create free account
hub / github.com/Craig-Macomber/lol_alloc / AssumeSingleThreaded

Class AssumeSingleThreaded

lol_alloc/src/single_threaded_allocator.rs:6–8  ·  view source on GitHub ↗

A non-thread safe allocator created by wrapping an allocator in a `Sync` implementation that assumes all use is from the same thread. Using this (and thus defeating Rust's thread safety checking) is useful due to global allocators having to be stored in statics, which requires `Sync` even in single threaded applications.

Source from the content-addressed store, hash-verified

4/// Using this (and thus defeating Rust's thread safety checking) is useful due to global allocators having to be stored in statics,
5/// which requires `Sync` even in single threaded applications.
6pub struct AssumeSingleThreaded<T> {
7 inner: T,
8}
9
10impl<T> AssumeSingleThreaded<T> {
11 /// Converts a potentially non-`Sync` allocator into a `Sync` one by assuming it will only be used by one thread.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected