|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Wrapper for std::jthread or std::thread with manual stop mechanism. More...
#include <jthread_compat.h>

Public Member Functions | |
| compat_jthread () noexcept=default | |
| Default constructor - no thread. | |
| template<typename F > | |
| compat_jthread (F &&func) | |
| Construct and start thread with stop token support. | |
| ~compat_jthread () | |
| Destructor - requests stop and joins. | |
| compat_jthread (const compat_jthread &)=delete | |
| compat_jthread & | operator= (const compat_jthread &)=delete |
| compat_jthread (compat_jthread &&other) noexcept | |
| compat_jthread & | operator= (compat_jthread &&other) noexcept |
| bool | joinable () const noexcept |
| Check if thread is joinable. | |
| void | request_stop () |
| Request the thread to stop. | |
| void | join () |
| Wait for thread to complete. | |
| std::shared_ptr< simple_stop_source > | get_stop_source () const noexcept |
| Get the stop source (fallback mode only) | |
Private Attributes | |
| std::shared_ptr< simple_stop_source > | stop_source_ |
| std::thread | thread_ |
Wrapper for std::jthread or std::thread with manual stop mechanism.
When KCENON_HAS_JTHREAD is true, this is a thin wrapper around std::jthread. When KCENON_HAS_JTHREAD is false, this provides equivalent functionality using std::thread with a simple_stop_source.
Definition at line 84 of file jthread_compat.h.
|
defaultnoexcept |
Default constructor - no thread.
|
inlineexplicit |
Construct and start thread with stop token support.
| F | Callable type |
| func | Function to run in thread |
The function signature should be:
Definition at line 106 of file jthread_compat.h.
|
inline |
Destructor - requests stop and joins.
Definition at line 116 of file jthread_compat.h.
References join(), joinable(), and request_stop().

|
delete |
|
inlinenoexcept |
Definition at line 128 of file jthread_compat.h.
|
inlinenodiscardnoexcept |
Get the stop source (fallback mode only)
This is used by async_worker to pass the stop source to the worker loop, ensuring the same stop source is used for both request_stop() and stop_requested() checks.
Definition at line 200 of file jthread_compat.h.
References stop_source_.
|
inline |
Wait for thread to complete.
Definition at line 179 of file jthread_compat.h.
References thread_.
Referenced by operator=(), kcenon::logger::async::async_worker::stop(), kcenon::logger::async::batch_processing_jthread_worker::stop(), kcenon::logger::log_collector_jthread_worker::stop(), kcenon::logger::network_reconnect_jthread_worker::stop(), kcenon::logger::network_send_jthread_worker::stop(), and ~compat_jthread().

|
inlinenodiscardnoexcept |
Check if thread is joinable.
Definition at line 155 of file jthread_compat.h.
References thread_.
Referenced by operator=(), and ~compat_jthread().

|
inlinenoexcept |
Definition at line 136 of file jthread_compat.h.
References join(), joinable(), request_stop(), stop_source_, and thread_.

|
delete |
|
inline |
Request the thread to stop.
Definition at line 166 of file jthread_compat.h.
References stop_source_, and thread_.
Referenced by operator=(), kcenon::logger::async::async_worker::stop(), kcenon::logger::async::batch_processing_jthread_worker::stop(), kcenon::logger::log_collector_jthread_worker::stop(), kcenon::logger::network_reconnect_jthread_worker::stop(), kcenon::logger::network_send_jthread_worker::stop(), and ~compat_jthread().

|
private |
Definition at line 209 of file jthread_compat.h.
Referenced by get_stop_source(), operator=(), and request_stop().
|
private |
Definition at line 210 of file jthread_compat.h.
Referenced by join(), joinable(), operator=(), and request_stop().