Space Engineers
Classes | Public Member Functions | Static Public Member Functions | Properties | List of all members
VRage.Library.Algorithms.SequenceIdGenerator Class Reference

Generates IDs sequentially and reuses old IDs which are returned to pool by calling Return method. Protection count and time can be set to protect returned IDs. Protection is useful especially in multiplayer where clients can still have objects with those IDs. More...

Public Member Functions

 SequenceIdGenerator (int reuseProtectionCount=2048, uint reuseProtectionTime=60, Func< uint > timeFunc=null)
 
void Reserve (uint reservedIdCount)
 Reserves first several IDs, so it's never returned by generator. Zero is never returned, when reservedIdCount is 2, IDs 1 and 2 won't be ever returned. More...
 
uint NextId ()
 
void Return (uint id)
 

Static Public Member Functions

static SequenceIdGenerator CreateWithStopwatch (TimeSpan reuseProtectionTime, int reuseProtectionCount=2048)
 Creates new sequence id generator with stopwatch to measure protection time. More...
 

Properties

int WaitingInQueue [get]
 
uint ReservedCount [get]
 Number of reserved ids, zero is also reserved, but not counted. More...
 

Detailed Description

Generates IDs sequentially and reuses old IDs which are returned to pool by calling Return method. Protection count and time can be set to protect returned IDs. Protection is useful especially in multiplayer where clients can still have objects with those IDs.

Definition at line 15 of file SequenceIdGenerator.cs.

Constructor & Destructor Documentation

VRage.Library.Algorithms.SequenceIdGenerator.SequenceIdGenerator ( int  reuseProtectionCount = 2048,
uint  reuseProtectionTime = 60,
Func< uint >  timeFunc = null 
)
inline

Definition at line 64 of file SequenceIdGenerator.cs.

Member Function Documentation

static SequenceIdGenerator VRage.Library.Algorithms.SequenceIdGenerator.CreateWithStopwatch ( TimeSpan  reuseProtectionTime,
int  reuseProtectionCount = 2048 
)
inlinestatic

Creates new sequence id generator with stopwatch to measure protection time.

Parameters
reuseProtectionTimeTime to protect returned IDs.
reuseProtectionCountMinimum number of IDs in protection queue, before first ID will be reused.

Definition at line 77 of file SequenceIdGenerator.cs.

uint VRage.Library.Algorithms.SequenceIdGenerator.NextId ( )
inline

Definition at line 126 of file SequenceIdGenerator.cs.

void VRage.Library.Algorithms.SequenceIdGenerator.Reserve ( uint  reservedIdCount)
inline

Reserves first several IDs, so it's never returned by generator. Zero is never returned, when reservedIdCount is 2, IDs 1 and 2 won't be ever returned.

Parameters
reservedIdCountNumber of reserved IDs which will be never returned by generator.

Definition at line 95 of file SequenceIdGenerator.cs.

void VRage.Library.Algorithms.SequenceIdGenerator.Return ( uint  id)
inline

Definition at line 137 of file SequenceIdGenerator.cs.

Property Documentation

uint VRage.Library.Algorithms.SequenceIdGenerator.ReservedCount
get

Number of reserved ids, zero is also reserved, but not counted.

Definition at line 62 of file SequenceIdGenerator.cs.

int VRage.Library.Algorithms.SequenceIdGenerator.WaitingInQueue
get

Definition at line 55 of file SequenceIdGenerator.cs.


The documentation for this class was generated from the following file: