BlockAllocator

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph cluster_builtins { graph [label=builtins]; node [color=1]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_supriya.realtime" { graph [label="supriya.realtime"]; node [color=2]; "supriya.realtime.BlockAllocator.BlockAllocator" [URL="../api/supriya/realtime/BlockAllocator.html#supriya.realtime.BlockAllocator.BlockAllocator", color=black, fontcolor=white, label="Block\nAllocator", target=_top]; } subgraph "cluster_supriya.system" { graph [label="supriya.system"]; node [color=3]; "supriya.system.SupriyaObject.SupriyaObject" [URL="../api/supriya/realtime/../system/SupriyaObject.html#supriya.system.SupriyaObject.SupriyaObject", label="Supriya\nObject", target=_top]; } "builtins.object" -> "supriya.system.SupriyaObject.SupriyaObject"; "supriya.system.SupriyaObject.SupriyaObject" -> "supriya.realtime.BlockAllocator.BlockAllocator"; }

class supriya.realtime.BlockAllocator.BlockAllocator(heap_maximum=None, heap_minimum=0)[source]

A block allocator.

>>> import supriya.realtime
>>> allocator = supriya.realtime.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

Attributes Summary

allocate
allocate_at
free
heap_maximum Maximum allocatable index.
heap_minimum Minimum allocatable index.

Special methods

(SupriyaObject).__repr__()

Return repr(self).


Methods

allocate(desired_block_size=1)[source]
allocate_at(index=None, desired_block_size=1)[source]
free(block_id)[source]

Read-only properties

heap_maximum

Maximum allocatable index.

heap_minimum

Minimum allocatable index.