TokenHandler class¶
This is a simple way to provide tokens for various reasons.
Member Functions¶
TokenHandler(void)¶
Initialize the index to -1
create the access semaphore
create the exclude list with no items
~TokenHandler(void)¶
delete the access lock
call ResetExcludes and delete the exclude list
int32 GetToken(void)¶
Returns a unique token which is not equal to any excluded values
create a local variable to return the new token
acquire the access semaphore
Increment the internal index
while IsExclude(index) is true, increment the index
assign it to the local variable
release the access semaphore
return the local variable
void Reset(void)¶
acquire the access semaphore
set the internal index to -1
release the access semaphore
void ExcludeValue(int32 value)¶
acquire the access semaphore
if IsExclude(value) is false, add it to the exclude list
release the access semaphore
void ResetExcludes(void)¶
acquire the access semaphore
Iterate through the exclude list, removing and deleting each item
release the access semaphore
bool IsExclude(int32 value)¶
create a boolean match flag and set it to false
acquire the access semaphore
iterate through the exclude list and see if the value matches any in the list
If there is a match, set the match flag to true and exit the loop
release the access semaphore
return the match flag