Segregator

A Segregator with more than three arguments expands to a composition of elemental Segregators, as illustrated by the following example:

alias A =
    Segregator!(
        n1, A1,
        n2, A2,
        n3, A3,
        A4
    );

With this definition, allocation requests for n1 bytes or less are directed to A1; requests between n1 + 1 and n2 bytes (inclusive) are directed to A2; requests between n2 + 1 and n3 bytes (inclusive) are directed to A3; and requests for more than n3 bytes are directed to A4. If some particular range should not be handled, NullAllocator may be used appropriately.

Members

Aliases

Segregator
alias Segregator = .Segregator!(Args[cutPoint], .Segregator!(Args[0..cutPoint], Args[cutPoint + 1]), .Segregator!(Args[cutPoint + 2..$]))
Undocumented in source.
Segregator
alias Segregator = .Segregator!(Args[0], Args[1], .Segregator!(Args[2..$]))
Undocumented in source.

Examples

import stdx.allocator.building_blocks.free_list : FreeList;
import stdx.allocator.gc_allocator : GCAllocator;
import stdx.allocator.mallocator : Mallocator;
alias A =
    Segregator!(
        128, FreeList!(Mallocator, 0, 128),
        1024 * 4, GCAllocator,
        1024 * 1024, Mallocator,
        GCAllocator
    );
A a;
auto b = a.allocate(201);
assert(b.length == 201);
a.deallocate(b);

Meta