1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
TITLE:: ReadableNodeIDAllocator
summary:: an allocator for nodeIDs with human-readable ownership
categories:: Control
related:: Classes/Server, Guides/MultiClient_Setups
DESCRIPTION::
In multi-client setups, it is useful to know which client created which nodeIDs on a shared server. ReadableNodeIDAllocator provides that facility by using a decimal prefix based on the clientID.
code::
// default server uses a ReadableNodeIDAllocator
s.nodeAllocator;
s.nodeAllocator.userID; // its userID is
s.clientID
// which creates this defaultGroup 1
s.defaultGroup;
s.defaultGroupID;
// and temp nodes begin with 1000 ...
3.do { s.nextNodeID.postln };
// make a dummy server with different clientID
r = Server(\remote4, s.addr, s.options, clientID: 4);
// defaultGroup begins with 400000 ... prefix and ends with 1
r.defaultGroup;
r.defaultGroupID;
// and temp nodes begin with 400001000 ...
3.do { r.nextNodeID.postln };
::
CLASSMETHODS::
METHOD:: new
make a new instance for given clientID, offset for lowest temporary id, and
argument:: clientID
the clientID for which to create an offset/prefix
argument:: lowestTempID
the offset for the lowest temporary id
argument:: numClients
the number of clients for which to split the number range
code::
// make an allocator with id 11
a = ReadableNodeIDAllocator(11, 1000, 12);
// begins with 1100000 ... prefix
3.do { a.alloc.postln };
::
INSTANCEMETHODS::
METHOD:: clientID
the clientID for which to create an offset/prefix
METHOD:: numClients
the number of clients for which to split the number range
METHOD:: lowestTempID
the offset from where temporary nodeID begin
METHOD:: idOffset
the offset from where nodeID range begins
METHOD:: maxPermID
the highest permanent nodeID
METHOD:: numIDs
the number of IDs before the allocator will wrap
METHOD:: alloc
allocate next temporary nodeID
METHOD:: allocPerm
allocate next permanent nodeID
METHOD:: freePerm
free a permanent nodeID
argument:: id
METHOD:: isPerm
test whether num is in the allocator's range of permanent numbers
argument:: num
METHOD:: reset
reset allocator to initial state
|