Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
JournalThreader Class Reference

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

ThreadLinenextLine ()
 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...
 
ThreadLinethreadLine (int thread)
 Get the line object for the supplied thread, typically for the current thread. More...
 

Private Attributes

std::map< int, ThreadLinem_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...
 

Detailed Description

Manages threaded writes for the Journaller objects.

Definition at line 79 of file journalthreader.h.

Constructor & Destructor Documentation

◆ JournalThreader()

JournalThreader::JournalThreader ( )

Constructor, sets up the necessary structures for threaded logging.

Definition at line 80 of file journalthreader.cpp.

◆ ~JournalThreader()

JournalThreader::~JournalThreader ( )

Destructor, flushes all remaining data.

Definition at line 86 of file journalthreader.cpp.

Member Function Documentation

◆ cleanup()

void JournalThreader::cleanup ( int  id)

Remove the thread-local storage for thread id.

Parameters
idThe thread to remove

Definition at line 159 of file journalthreader.cpp.

◆ flushAll()

void JournalThreader::flushAll ( JournalFile file)

Flush all available non-empty lines to the supplied file, clearing lines as they are flushed.

Parameters
fileThe file to write to. Supply nullptr to write to the debug output

Definition at line 93 of file journalthreader.cpp.

◆ line()

std::string & JournalThreader::line ( int  thread)
Returns
The reference to the line associated with the given file and thread
Parameters
threadThe thread id associated with the line, ignored when JOURNALLER_WITH_THREAD_SUPPORT == 0

Definition at line 150 of file journalthreader.cpp.

◆ lineLevel()

JournalLogLevel JournalThreader::lineLevel ( int  thread)
Returns
The log level of the queued line
Parameters
threadThe thread id associated with the line

Definition at line 141 of file journalthreader.cpp.

◆ nextLine()

ThreadLine& JournalThreader::nextLine ( )
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.

◆ setLineLevel()

JournalLogLevel JournalThreader::setLineLevel ( int  thread,
JournalLogLevel  level 
)

Set the log level of the queued line.

Parameters
threadThe thread id associated with the line
levelThe log level to set
Returns
The old log level

Definition at line 130 of file journalthreader.cpp.

◆ threadLine()

ThreadLine& JournalThreader::threadLine ( int  thread)
inlineprivate

Get the line object for the supplied thread, typically for the current thread.

Definition at line 110 of file journalthreader.h.

◆ writeLine()

void JournalThreader::writeLine ( int  thread,
JournalFile file 
)

Write the line for thread thread to file file.

Parameters
threadThe thread id associated with the line
fileThe file to write to. Supply nullptr to write to the debug output

Definition at line 113 of file journalthreader.cpp.

Member Data Documentation

◆ m_map

std::map<int, ThreadLine> JournalThreader::m_map
private

The contained lines, one for each thread.

Definition at line 106 of file journalthreader.h.

◆ m_mutex

xsens::Mutex JournalThreader::m_mutex
mutableprivate

A mutex guarding access to the map (not to the lines)

Definition at line 107 of file journalthreader.h.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:21