Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
Semaphore protected queue for a single producer and a single consumer thread. More...
#include <FXSemaQueue.h>
Public Member Functions | |
FXSemaQueue (FXival sz=32) | |
Create initially empty queue of given size sz. | |
FXival | getSize () const |
Return size. | |
FXbool | push (FXptr ptr) |
Add item to queue, return true if success. | |
FXbool | trypush (FXptr obj) |
Try push object into queue. | |
FXbool | trypush (FXptr obj, FXTime nsec) |
Try push object into queue, waiting up to nsec for space to become available. More... | |
FXbool | pop (FXptr &ptr) |
Remove item from queue, return true if success. | |
FXbool | trypop (FXptr &obj) |
Try pop object from queue. | |
FXbool | trypop (FXptr &obj, FXTime nsec) |
Try pop object from queue, waiting up to nsec for object to become available. More... | |
FXbool | pop () |
Drop item from queue, return true if success. | |
~FXSemaQueue () | |
Destroy queue. | |
Semaphore protected queue for a single producer and a single consumer thread.
Producer thread will only block in push() when the queue is full; likewise, consumer will only block in pop() if the queue is empty. To avoid blocking the producer, call trypush() instead. Without timeout parameter, trypush() will return immediately if no space is available. When the timeout parameter is passed, the producer will wait a finite amount of time before giving up. Similarly, to avoid blocking the consumer, call trypop(). Without the timeout parameter, trypop() will return immediately if no items are available. When the timeout parameter is passed, the consumer will wait a finite amount of time before giving up.
FXbool FX::FXSemaQueue::trypop | ( | FXptr & | obj, |
FXTime | nsec | ||
) |
Try pop object from queue, waiting up to nsec for object to become available.
FXbool FX::FXSemaQueue::trypush | ( | FXptr | obj, |
FXTime | nsec | ||
) |
Try push object into queue, waiting up to nsec for space to become available.
Copyright © 1997-2022 Jeroen van der Zijp |