xref: /haiku/docs/develop/servers/app_server/TokenHandler.rst (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
1TokenHandler class
2##################
3
4This is a simple way to provide tokens for various reasons.
5
6Member Functions
7================
8
9TokenHandler(void)
10------------------
11
121. Initialize the index to -1
132. create the access semaphore
143. create the exclude list with no items
15
16~TokenHandler(void)
17-------------------
18
191. delete the access lock
202. call ResetExcludes and delete the exclude list
21
22int32 GetToken(void)
23--------------------
24
25Returns a unique token which is not equal to any excluded values
26
271. create a local variable to return the new token
282. acquire the access semaphore
293. Increment the internal index
304. while IsExclude(index) is true, increment the index
315. assign it to the local variable
326. release the access semaphore
337. return the local variable
34
35void Reset(void)
36----------------
37
381. acquire the access semaphore
392. set the internal index to -1
403. release the access semaphore
41
42void ExcludeValue(int32 value)
43------------------------------
44
451. acquire the access semaphore
462. if IsExclude(value) is false, add it to the exclude list
473. release the access semaphore
48
49void ResetExcludes(void)
50------------------------
51
521. acquire the access semaphore
532. Iterate through the exclude list, removing and deleting each item
543. release the access semaphore
55
56bool IsExclude(int32 value)
57---------------------------
58
591. create a boolean match flag and set it to false
602. acquire the access semaphore
613. iterate through the exclude list and see if the value matches any in
62   the list
634. If there is a match, set the match flag to true and exit the loop
645. release the access semaphore
656. return the match flag
66
67