Manages threaded writes for the Journaller objects. More...
#include <journalthreader.h>
Classes | |
| class | ThreadLine |
| Storage for logging queue of a specific thread. More... | |
Public Member Functions | |
| void | cleanup (int id) |
| Remove the thread-local storage for thread id. More... | |
| void | flushAll (JournalFile *file) |
| Flush all available non-empty lines to the supplied file, clearing lines as they are flushed. More... | |
| JournalThreader () | |
| Constructor, sets up the necessary structures for threaded logging. More... | |
| std::string & | line (int thread) |
| JournalLogLevel | lineLevel (int thread) |
| JournalLogLevel | setLineLevel (int thread, JournalLogLevel level) |
| Set the log level of the queued line. More... | |
| void | writeLine (int thread, JournalFile *file) |
| Write the line for thread thread to file file. More... | |
| ~JournalThreader () | |
| Destructor, flushes all remaining data. More... | |
Private Member Functions | |
| ThreadLine & | nextLine () |
| Get the next non-empty line object from the map of all threads, returns an empty line object if no non-empty objects were available. More... | |
| ThreadLine & | threadLine (int thread) |
| Get the line object for the supplied thread, typically for the current thread. More... | |
Private Attributes | |
| std::map< int, ThreadLine > | m_map |
| The contained lines, one for each thread. More... | |
| xsens::Mutex | m_mutex |
| A mutex guarding access to the map (not to the lines) More... | |
Manages threaded writes for the Journaller objects.
Definition at line 79 of file journalthreader.h.
| JournalThreader::JournalThreader | ( | ) |
Constructor, sets up the necessary structures for threaded logging.
Definition at line 80 of file journalthreader.cpp.
| JournalThreader::~JournalThreader | ( | ) |
Destructor, flushes all remaining data.
Definition at line 86 of file journalthreader.cpp.
| void JournalThreader::cleanup | ( | int | id | ) |
Remove the thread-local storage for thread id.
| id | The thread to remove |
Definition at line 159 of file journalthreader.cpp.
| void JournalThreader::flushAll | ( | JournalFile * | file | ) |
Flush all available non-empty lines to the supplied file, clearing lines as they are flushed.
| file | The file to write to. Supply nullptr to write to the debug output |
Definition at line 93 of file journalthreader.cpp.
| std::string & JournalThreader::line | ( | int | thread | ) |
| thread | The thread id associated with the line, ignored when JOURNALLER_WITH_THREAD_SUPPORT == 0 |
Definition at line 150 of file journalthreader.cpp.
| JournalLogLevel JournalThreader::lineLevel | ( | int | thread | ) |
| thread | The thread id associated with the line |
Definition at line 141 of file journalthreader.cpp.
|
inlineprivate |
Get the next non-empty line object from the map of all threads, returns an empty line object if no non-empty objects were available.
Definition at line 117 of file journalthreader.h.
| JournalLogLevel JournalThreader::setLineLevel | ( | int | thread, |
| JournalLogLevel | level | ||
| ) |
Set the log level of the queued line.
| thread | The thread id associated with the line |
| level | The log level to set |
Definition at line 130 of file journalthreader.cpp.
|
inlineprivate |
Get the line object for the supplied thread, typically for the current thread.
Definition at line 110 of file journalthreader.h.
| void JournalThreader::writeLine | ( | int | thread, |
| JournalFile * | file | ||
| ) |
Write the line for thread thread to file file.
| thread | The thread id associated with the line |
| file | The file to write to. Supply nullptr to write to the debug output |
Definition at line 113 of file journalthreader.cpp.
|
private |
The contained lines, one for each thread.
Definition at line 106 of file journalthreader.h.
|
mutableprivate |
A mutex guarding access to the map (not to the lines)
Definition at line 107 of file journalthreader.h.