allocators¶
-
class Block(start_offset: float =
-inf
, stop_offset: float =inf
, used: bool =False
)¶ Bases:
Interval
-
class BlockAllocator(heap_maximum: int | None =
None
, heap_minimum: int =0
)¶ Bases:
object
A block allocator.
>>> from supriya.contexts.allocators import BlockAllocator >>> allocator = BlockAllocator( ... heap_maximum=16, ... )
>>> allocator.allocate(4) 0
>>> allocator.allocate(4) 4
>>> allocator.allocate(4) 8
>>> allocator.allocate(8) is None True
>>> allocator.free(8) >>> allocator.allocate(8) 8
-
allocate(desired_block_size: int =
1
) int | None ¶
-
allocate(desired_block_size: int =
-
class NodeIdAllocator(client_id: int =
0
, initial_node_id: int =1000
, locked=True
)¶ Bases:
object
A node ID allocator.
>>> from supriya.contexts.allocators import NodeIdAllocator >>> allocator = NodeIdAllocator() >>> for _ in range(3): ... allocator.allocate_node_id() ... 1000 1001 1002
>>> for _ in range(3): ... allocator.allocate_permanent_node_id() ... 1 2 3
>>> allocator.free_permanent_node_id(2)
>>> allocator.allocate_permanent_node_id() 2