Loading...
Searching...
No Matches
dcmtk::log4cplus::thread::Queue Class Reference

Single consumer, multiple producers queue. More...

Inheritance diagram for dcmtk::log4cplus::thread::Queue:

## Public Types

enum | Flags { EVENT = 0x0001 , QUEUE = 0x0002 , EXIT = 0x0004 , DRAIN = 0x0008 , ERROR_BIT = 0x0010 , ERROR_AFTER = 0x0020 }
| Possible state flags. More...
typedef unsigned | flags_type
| Type of the state flags field.
typedef OFVector< spi::InternalLoggingEvent > | queue_storage_type
| Queue storage type.

## Public Member Functions

flags_type | put_event (spi::InternalLoggingEvent const &ev)
flags_type | signal_exit (bool drain=true)
flags_type | get_events (queue_storage_type *buf)

## 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.

## Detailed Description

Single consumer, multiple producers queue.

## Member Enumeration Documentation

## Flags

enum dcmtk::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 occurred after queue has already been touched.

## Member Function Documentation

## get_events()

flags_type dcmtk::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

  buf | Pointer to storage of spi::InternalLoggingEvent instances to be filled from queue.

Returns
  Flags.

## put_event()

flags_type dcmtk::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

  ev | spi::InternalLoggingEvent to be put into the queue.

Returns
  Flags.

## signal_exit()

flags_type dcmtk::log4cplus::thread::Queue::signal_exit | ( | bool | drain = true | ) |

Sets EXIT flag and DRAIN flag and sets internal event object into signaled state.

Parameters

  drain | If true, DRAIN flag will be set, otherwise unset.

Returns
  Flags, ERROR_BIT can be set upon error.

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

- oflog/include/dcmtk/oflog/helpers/queue.h

Generated on for DCMTK Version 3.7.0 by Doxygen 1.15.0