pub trait Config: Sized {
const MAX_THREADS: usize = 4_096usize;
const MAX_PAGES: usize = 32usize;
const INITIAL_PAGE_SIZE: usize = 32usize;
const RESERVED_BITS: usize = 0usize;
}
Expand description
Configuration parameters which can be overridden to tune the behavior of a slab.
Provided Associated Constants§
Sourceconst MAX_THREADS: usize = 4_096usize
const MAX_THREADS: usize = 4_096usize
The maximum number of threads which can access the slab.
This value (rounded to a power of two) determines the number of shards in the slab. If a thread is created, accesses the slab, and then terminates, its shard may be reused and thus does not count against the maximum number of threads once the thread has terminated.
Sourceconst MAX_PAGES: usize = 32usize
const MAX_PAGES: usize = 32usize
The maximum number of pages in each shard in the slab.
This value, in combination with INITIAL_PAGE_SIZE
, determines how many
bits of each index are used to represent page addresses.
Sourceconst INITIAL_PAGE_SIZE: usize = 32usize
const INITIAL_PAGE_SIZE: usize = 32usize
The size of the first page in each shard.
When a page in a shard has been filled with values, a new page will be allocated that is twice as large as the previous page. Thus, the second page will be twice this size, and the third will be four times this size, and so on.
Note that page sizes must be powers of two. If this value is not a power of two, it will be rounded to the next power of two.
Sourceconst RESERVED_BITS: usize = 0usize
const RESERVED_BITS: usize = 0usize
Sets a number of high-order bits in each index which are reserved from user code.
Note that these bits are taken from the generation counter; if the page address and thread IDs are configured to use a large number of bits, reserving additional bits will decrease the period of the generation counter. These should thus be used relatively sparingly, to ensure that generation counters are able to effectively prevent the ABA problem.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.