allocators¶
-
class Block(start_offset: float =
-inf
, stop_offset: float =inf
, used: bool =False
)¶ Bases:
Interval
-
class BlockAllocator(heap_maximum=
None
, heap_minimum=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=
1
)¶
-
allocate_at(index=
None
, desired_block_size=1
)¶
- free(block_id)¶
- property heap_maximum¶
Maximum allocatable index.
- property heap_minimum¶
Minimum allocatable index.
-
allocate(desired_block_size=
-
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