hsc3-server-0.10.0: SuperCollider server resource management and synchronization.

Safe HaskellSafe-Inferred
LanguageHaskell98

Sound.SC3.Server.Allocator

Contents

Synopsis

Allocation errors

data AllocFailure Source

Failure type for allocators.

Constructors

NoFreeIds

There are no free ids left in the allocator.

InvalidId

The id being released has not been allocated by this allocator.

Allocator statistics

data Statistics Source

Simple allocator usage statistics.

Constructors

Statistics 

Fields

numAvailable :: Int

Total number of available identifiers

numFree :: Int

Number of currently available identifiers

numUsed :: Int

Number of identifiers currently in use

percentFree :: Statistics -> Double Source

Percentage of currently available identifiers.

percentFree s = numFree s / numAvailable s
percentFree s + percentUsed s = 1

percentUsed :: Statistics -> Double Source

Percentage of identifiers currently in use.

percentUsed s = numUsed s / numAvailable s
percentUsed s + percentFree s = 1

Allocator classes

class IdAllocator a where Source

IdAllocator provides an interface for allocating and releasing identifiers that correspond to server resources, such as node, buffer and bus ids.

Associated Types

type Id a Source

Id type allocated by this allocator.

Methods

alloc :: Failure AllocFailure m => a -> m (Id a, a) Source

Allocate a new identifier and return the changed allocator.

free :: Failure AllocFailure m => Id a -> a -> m a Source

Free a previously allocated identifier and return the changed allocator.

Freeing an identifier that hasn't been allocated with this allocator may trigger a failure.

statistics :: a -> Statistics Source

Return usage statistics.

allocMany :: (IdAllocator a, Failure AllocFailure m) => Int -> a -> m ([Id a], a) Source

Allocate a number of (not necessarily consecutive) IDs with the given allocator.

Returns the list of IDs and the modified allocator.

freeMany :: (IdAllocator a, Failure AllocFailure m) => [Id a] -> a -> m a Source

Free a number of IDs with the given allocator.

Returns the modified allocator.

class IdAllocator a => RangeAllocator a where Source

RangeAllocator provides an interface for allocating and releasing ranges of consecutive identifiers.

Methods

allocRange :: Failure AllocFailure m => Int -> a -> m (Range (Id a), a) Source

Allocate n consecutive identifiers and return the changed allocator.

freeRange :: Failure AllocFailure m => Range (Id a) -> a -> m a Source

Free a range of previously allocated identifiers and return the changed allocator.