| Qore Logger Module Reference 1.0

Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Logger::LoggerAppenderQueueThreadPool Class Reference

Handles the processing for asynchronous appender events in multiple threads. More...

## Public Member Functions
| constructor (ThreadPool tp, int max_threads=-1)
| Creates the object.
ThreadPool | getThreadPool ()
| Returns the assigned ThreadPool.
| process (timeout ms=0)
| Processes queue events.
int | size ()
| Gets number of pending events.

## Private Member Functions
Queue | finishedEvents ()
| queue of processed events in worker threads
Sequence | lastId (0)
| internal unique counter
Mutex | lock ()
| to protect process()
Counter | runningCounter (0)
| number of running worker threads
| worker (string id, LoggerAppender appender, list< auto > events)
| Implements worker thread code.

## Private Attributes
int | maxThreads
| max.number of worker threads
hash< auto > | pendingEvents
| events removed from queue but not passed to worker thread
hash< auto > | processingEvents
| events paseed to worker thread
ThreadPool | threadPool
| worker thread pool

## Detailed Description

Handles the processing for asynchronous appender events in multiple threads.

Async events are removed from the event queue in a single thread which balances processing in multiple worker threads via a ThreadPool. This class groups events by appender so that events related to a particular appender are always processed serially in the same thread. It is compatible with Qore's Qore::OutputStream implementation where all data submitted to the output stream must be submitted from the same thread.

## Member Function Documentation

## ◆ constructor()

Logger::LoggerAppenderQueueThreadPool::constructor | ( | ThreadPool | tp,
|  | int | max_threads = -1 )

Creates the object.

Parameters

  tp | worker ThreadPool where loggging events are submitted
  max_threads | max.number of worker threads, default value is `-1`, i.e. unlimited

## ◆ process()

Logger::LoggerAppenderQueueThreadPool::process | ( | timeout | ms = 0 | ) |

Processes queue events.

Group logging events by appender and submit them to a worker thread to be processed in a thread pool so the particular thread will handle corresponding appender instance.

Parameters

  ms | a timeout value to wait for data to become available on the queue; integers are interpreted as milliseconds; relative date/time values are interpreted literally with a maximum resolution of milliseconds. A value that converts to integer 0 causes the call to time out immediately if the call would otherwise block. If a positive timeout argument is passed, and no data is available in the timeout period then waits up to timeout value, If a negative timeout value is passed as the argument, then the call blocks until data is available on the queue. Default value is 0.

## ◆ worker()

Logger::LoggerAppenderQueueThreadPool::worker | ( | string | id,
|  | LoggerAppender | appender,
|  | list< auto > | events )
| private

Implements worker thread code.

Parameters

  id | unique identifier generated by internal Sequence
  appender | LoggerAppender instance
  events | list of events