Qore Logger Module Reference
0.1
|
Handles the processing for asynchronous appender events in multiple threads. More...
Public Member Methods | |
constructor (ThreadPool tp, int max_threads=-1) | |
Creates the object. More... | |
ThreadPool | getThreadPool () |
Returns the assigned ThreadPool. | |
process (timeout ms=0) | |
Processes queue events. More... | |
int | size () |
Gets number of pending events. | |
Public Member Methods inherited from Logger::LoggerAppenderQueue | |
process (timeout ms=0) | |
Processes queued events. More... | |
bool | push (LoggerAppender appender, int type, auto params) |
Adds appender event. More... | |
int | size () |
Returns the current number of events waiting in queue. | |
Private:Internal Member Methods | |
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 events) | |
Implements worker thread code. More... | |
Private:Internal Attributes | |
int | maxThreads |
max.number of worker threads | |
hash | pendingEvents |
events removed from queue but not passed to worker thread | |
hash | processingEvents |
events paseed to worker thread | |
ThreadPool | threadPool |
worker thread pool | |
Additional Inherited Members | |
Private Member Methods inherited from Logger::LoggerAppenderQueue | |
*hash | getEvent (timeout ms) |
Returns the next event from queue or NOTHING if there is no event available within the timeout period. More... | |
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.
Logger::LoggerAppenderQueueThreadPool::constructor | ( | ThreadPool | tp, |
int | max_threads = -1 |
||
) |
Creates the object.
tp | worker ThreadPool where loggging events are submitted |
max_threads | max.number of worker threads, default value is -1 , i.e. unlimited |
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.
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. |
|
private:internal |
Implements worker thread code.
id | unique identifier generated by internal Sequence |
appender | LoggerAppender instance |
events | list of events |