The TGXbStack() class allow to implement sync/async stacks or queues and also can be used as a semaphore to serialize the access to the resources.
Class Methods:
::New( lSyncMode = .F. )
Create a new instance of the TGXbStack()class. If lSyncMode is .T. a critical section object will be used to serialize all method calls.
Instance Methods:
::Destroy() -> NIL
Release all allocated resources for this object. The ::Destroy() method need to be explicitly called.
::Tos() -> uItem
Return the item at the Top Of Stack.
::Tail() -> uItem
Return the base of the stack.
::Pop() -> uItem
Remove the item at the Top Of Stack and return it.
::Push(<uItem>) -> nItemCount
Add a new item at the Top Of Stack
::Add(<uItem>) -> nItemCount
Add a New Item at the Stack Base
::Count() -> nItemCount
Return the number of items
::SEval(<bEval> , @<uCargo>) -> NIL
::SEval() -> aItems
Eval a codeblock {|uItem,uCargo| ... } for every item from the top to the base of the stack. If no parameters return an array with all the items in the same order.
::QEval(<bEval> , @<uCargo>) -> NIL
::QEval() -> aItems
Eval a codeblock {|uItem,uCargo| ... } for every item from the base to the top of the stack. If no parameters return an array with all the items in the same order.
::Lock() -> NIL
If the object was created with the SyncMode flag wait until own the critical section rights.
There are no internal counter for the ::Lock() / ::Unlock() operations so cannot be safe to use nested.
::UnLock()
Unlock the critical section rights.