allocators

class Block(start_offset: float = - inf, stop_offset: float = inf, used: bool = False)

Bases: supriya.intervals.Interval.Interval

property used: bool
class BlockAllocator(heap_maximum=None, heap_minimum=0)

Bases: supriya.system.SupriyaObject

A block allocator.

>>> from supriya.realtime 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.

class NodeIdAllocator(client_id: int = 0, initial_node_id: int = 1000)

Bases: supriya.system.SupriyaObject

A node ID allocator.

>>> from supriya.realtime 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
allocate_node_id(count: int = 1) int
allocate_permanent_node_id() int
free_permanent_node_id(node_id: int) None