Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXSemaQueue Class Reference

Semaphore protected queue for a single producer and a single consumer thread. More...

#include <FXSemaQueue.h>

Inheritance diagram for FX::FXSemaQueue:
FX::FXSemaQueueOf< TYPE >

Public Member Functions

 FXSemaQueue (FXuint sz=32)
 Create initially empty queue of given size sz.
 
FXuint 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.
 

Detailed Description

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.

Member Function Documentation

◆ trypop()

FXbool FX::FXSemaQueue::trypop ( FXptr &  obj,
FXTime  nsec 
)

Try pop object from queue, waiting up to nsec for object to become available.

◆ trypush()

FXbool FX::FXSemaQueue::trypush ( FXptr  obj,
FXTime  nsec 
)

Try push object into queue, waiting up to nsec for space to become available.


The documentation for this class was generated from the following file:

Copyright © 1997-2020 Jeroen van der Zijp