Defined in file: hzLock.h
hzDiode: Lock free queue. Data throughput can be increased by multithreading in two ways: Either the threads do the same thing OR different threads handle different stages of the process (thread specialization). In the same-thing scenario, action must always be coordinated with locks. In the thread specialization scenario, objects completing one stage are queued up for the next thread to handle the next stage. Where stages are always applied in the same order, objects flow through the queues in one direction. Threads that write to the queue never read from it and threads that read from it never write to it. If there is only one writer thread the queue push operation can be lock free, and if there is only one reader thread the queue pull operation can be lock free. The hzDiode class is provided to exploit this simple case. Note that to avoid unessesary complications, hzDiode deals only in void* objects.
This class employes the private sub-class _bkt as follows:-
_bkt
Constructors/Detructors
| hzDiode* | hzDiode | (hzDiode& op) | |
| hzDiode* | hzDiode | (void) | |
| void | ~hzDiode | (void) | |
| NULL-TYPE | ~hzDiode | (void) | Delete this hzDiode instance, removing all allocated data object buckets |
Public Methods:
| void* | Pull | (void) | Pull data object from the to be processed queue. This is strickly done by the object receptor and processing thread. Arguments: None Pointer to the process object |
| void | Push | (void* pObj) | Push data object into the to be processed queue. This is done by the object originator thread. Returns: None |
| hzDiode::_bkt* | _alloc | (void) | Allocate a diode bucket from a freelist regime Arguments: None Pointer to the allocated bucket |
| void | _free | (hzDiode::_bkt* pB) | Put current block on free list Returns: None |
Member Variables:
| hzDiode::_bkt* | m_pFirst | First bucket | |
| hzDiode::_bkt* | m_pFree | Freelist of buckets | |
| hzDiode::_bkt* | m_pLast | Last bucket |