de.sciss.jcollider
Class PowerOfTwoAllocator

java.lang.Object
  extended by de.sciss.jcollider.PowerOfTwoAllocator
All Implemented Interfaces:
BlockAllocator

public class PowerOfTwoAllocator
extends java.lang.Object
implements BlockAllocator

Quite a 1:1 translation from SClang, this is used as the default bus allocator by the server.

Version:
0.32, 25-Feb-08
Author:
Hanns Holger Rutz
Todo:
unlike the node allocator, this cannot handle different client IDs. have to find out how different clients can peacefully coexist on the same server.

Nested Class Summary
static class PowerOfTwoAllocator.Factory
           
 
Constructor Summary
PowerOfTwoAllocator(int size)
           
PowerOfTwoAllocator(int size, int pos)
           
 
Method Summary
 int alloc(int n)
          Allocates a new bus.
 void free(int address)
          Frees a bus, that is makes it available again for new re-allocation.
 java.util.List getAllocatedBlocks()
          Queries a list of allocated blocks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PowerOfTwoAllocator

public PowerOfTwoAllocator(int size)

PowerOfTwoAllocator

public PowerOfTwoAllocator(int size,
                           int pos)
Method Detail

alloc

public int alloc(int n)
Description copied from interface: BlockAllocator
Allocates a new bus.

Specified by:
alloc in interface BlockAllocator
Parameters:
n - the number of channels to allocate. must be greater than zero.
Returns:
the address or index of the bus which is the index of the first channel. returns -1 if the allocator ran out of busses.

free

public void free(int address)
Description copied from interface: BlockAllocator
Frees a bus, that is makes it available again for new re-allocation.

Specified by:
free in interface BlockAllocator
Parameters:
address - the index of the bus

getAllocatedBlocks

public java.util.List getAllocatedBlocks()
Description copied from interface: BlockAllocator
Queries a list of allocated blocks. This can be usefull for debugging purposes.

Specified by:
getAllocatedBlocks in interface BlockAllocator
Returns:
a list whose elements are instances of Block