log4cplus_thread_Queue(3)
| log4cplus::thread::Queue(3) | log4cplus | log4cplus::thread::Queue(3) |
NAME
log4cplus::thread::Queue - Single consumer, multiple producers queue.
SYNOPSIS
#include <queue.h>
Inherits log4cplus::helpers::SharedObject.
Public Types
enum Flags { EVENT = 0x0001, QUEUE = 0x0002,
EXIT = 0x0004, DRAIN = 0x0008, ERROR_BIT = 0x0010,
ERROR_AFTER = 0x0020 }
Possible state flags. typedef unsigned flags_type
Type of the state flags field. typedef std::deque<
spi::InternalLoggingEvent > queue_storage_type
Queue storage type.
Public Member Functions
Queue (unsigned len=100)
virtual ~Queue ()
flags_type put_event (spi::InternalLoggingEvent const
&ev)
Puts event ev into queue, sets QUEUE flag and sets internal event object
into signaled state. flags_type signal_exit (bool
drain=true)
Sets EXIT flag and DRAIN flag and sets internal event object into signaled
state. flags_type get_events (queue_storage_type *buf)
The get_events() function is used by queue's consumer.
Protected Attributes
queue_storage_type queue
Queue storage. Mutex mutex
Mutex protecting queue and flags. ManualResetEvent
ev_consumer
Event on which consumer can wait if it finds queue empty. Semaphore
sem
Semaphore that limits the queue length. flags_type flags
State flags.
Additional Inherited Members
Detailed Description
Single consumer, multiple producers queue.
Definition at line 46 of file queue.h.
Member Typedef Documentation
typedef unsigned log4cplus::thread::Queue::flags_type
Type of the state flags field.
Definition at line 51 of file queue.h.
typedef std::deque<spi::InternalLoggingEvent> log4cplus::thread::Queue::queue_storage_type
Queue storage type.
Definition at line 54 of file queue.h.
Member Enumeration Documentation
enum log4cplus::thread::Queue::Flags
Possible state flags.
Enumerator
- EVENT
- EVENT flag is set in return value of get_event() call if the ev argument is filled with event from the queue.
- QUEUE
- QUEUE flag is set by producers when they put item into the queue.
- EXIT
- EXIT flag is set by signal_exit() call, signaling that the queue worker thread should end itself.
- DRAIN
- When DRAIN flag is set together with EXIT flag, the queue worker thread will first drain the queue before exiting.
- ERROR_BIT
- ERROR_BIT signals error.
- ERROR_AFTER
- ERROR_AFTER signals error that has occured after queue has already been touched.
Definition at line 102 of file queue.h.
Constructor & Destructor Documentation
log4cplus::thread::Queue::Queue (unsigned len = 100) [explicit]
virtual log4cplus::thread::Queue::~Queue () [virtual]
Member Function Documentation
flags_type log4cplus::thread::Queue::get_events (queue_storage_type * buf)
The get_events() function is used by queue's consumer. It fills buf argument and sets EVENT flag in return value. If EXIT flag is already set in flags member upon entering the function then depending on DRAIN flag it either fills buf argument or does not fill the argument, if the queue is non-empty. The function blocks by waiting for internal event object to be signaled if the queue is empty, unless EXIT flag is set. The calling thread is unblocked when items are added into the queue or when exit is signaled using the signal_exit() function.
Upon error, return value has one of the error flags set.
Parameters
Returns
flags_type log4cplus::thread::Queue::put_event (spi::InternalLoggingEvent const & ev)
Puts event ev into queue, sets QUEUE flag and sets internal event object into signaled state. If the EXIT flags is already set upon entering the function, nothing is inserted into the queue. The function can block on internal semaphore if the queue has reached maximal allowed length. Calling thread is unblocked either by consumer thread removing item from queue or by any other thread calling signal_exit().
Parameters
Returns
flags_type log4cplus::thread::Queue::signal_exit (bool drain = true)
Sets EXIT flag and DRAIN flag and sets internal event object into signaled state.
Parameters
Returns
Member Data Documentation
ManualResetEvent log4cplus::thread::Queue::ev_consumer [protected]
Event on which consumer can wait if it finds queue empty.
Definition at line 136 of file queue.h.
flags_type log4cplus::thread::Queue::flags [protected]
State flags.
Definition at line 142 of file queue.h.
Mutex log4cplus::thread::Queue::mutex [protected]
Mutex protecting queue and flags.
Definition at line 133 of file queue.h.
queue_storage_type log4cplus::thread::Queue::queue [protected]
Queue storage.
Definition at line 130 of file queue.h.
Semaphore log4cplus::thread::Queue::sem [protected]
Semaphore that limits the queue length.
Definition at line 139 of file queue.h.
Author
Generated automatically by Doxygen for log4cplus from the source code.
| Fri Jun 18 2021 | Version 2.0.6 |
