struct BackgroundThread { std::jthread flushThread; std::stop_token interruptThread {}; std::atomic<bool> cleanUpThreads {false }; std::atomic<bool> flushThreadEnabled {false }; std::atomic<bool> flushComplete {true }; std::atomic<bool> threadWriting {false }; std::atomic<bool> pauseThread {false }; };
Member Variables | |||||
---|---|---|---|---|---|
std::jthread |
flushThread
This thread object is used by Serenity for background flushing independent of the logging
thread(s).
|
||||
std::stop_token |
interruptThread
This stop token object is used, as the name implies, to interrupt the background flushing
thread as well as effectively terminates the flushing thread gracefully.
|
||||
std::atomic<bool> |
cleanUpThreads
This atomic variable is used to initiate, check, and notify the background flushing thread
when the main thread requests this thread to be destroyed.
|
||||
std::atomic<bool> |
flushThreadEnabled
This atomic variable is used in checks from the file logging thread(s) when writing to the
file buffer.
|
||||
std::atomic<bool> |
flushComplete
This atomic variable is used to notify the file logging thread(s) when a flush operation has
been completed.
|
||||
std::atomic<bool> |
threadWriting
This atomic variable is used to notify the background flushing thread when a logging
operation has been completed.
|
||||
std::atomic<bool> |
pauseThread
This atomic variable is used to notify the background flushing thread to temporarily halt
any flushing operations without destroying the thread itself.
|
std::jthread flushThread |
---|
This thread object handles background flushing of contents to the file and is the same thread that the other variables in this struct are primarily referencing in Serenity for communication between the logging thread(s) and the actual flushing of those logs to the file(s). |
std::stop_token interruptThread |
This stop token object is used, as the name implies, to interrupt the background flushing thread as well as effectively terminates the flushing thread gracefully. This is used specifically in the clean-up process on logger target destruction if the flushing thread was created. |
std::atomic<bool> cleanUpThreads |
This atomic variable is used to initiate, check, and notify the background flushing thread when the main thread requests this thread to be destroyed; this is used in tandem with the stop_token `interruptThread` during logger destruction. |
std::atomic<bool> flushThreadEnabled |
This atomic variable is set to `true` when the background flushing thread is instantiated and is used in checks from the file logging thread(s) when writing to the file buffer. |
std::atomic<bool> flushComplete |
This atomic variable is used to notify the file logging thread(s) when a flush operation has been completed and when it is safe to claim a light-weight ownership over the resource for continued logging before locking the mutex to aid in avoiding thread contention. |
std::atomic<bool> threadWriting |
This atomic variable is used to notify the background flushing thread when a logging operation has been completed and when it is safe to claim a light-weight ownership over the resource for continued flushing before locking the mutex to aid in avoiding thread contention. |
std::atomic<bool> pauseThread |
This atomic variable is used to notify the background flushing thread to temporarily halt
any flushing operations without destroying the thread itself. This is used more so with the
RotatingTarget based logger(s) when a file is currently in the process of being rotated
based on setting thresholds that have been met or in the case that the flush policies for
certain logger(s) has changed or if the period for flushing hasn't elapsed.
For Example:
|