|
| | LoggerBackend (Config &&config, ErrorHandler &&error_handler, ConsoleWriter &&console_writer=nullptr) |
| | Constructs and starts the asynchronous backend. More...
|
| |
| | ~LoggerBackend () override |
| | Drains records still pending at shutdown, flushes the file and stops the worker. More...
|
| |
| bool | log (Logger::Level level, std::string_view message) noexcept |
| | Enqueues one record. More...
|
| |
| void | flush () noexcept |
| | Drains non-evicted records preceding the barrier and flushes the active file. More...
|
| |
| void | enable_backtrace (size_t size) noexcept |
| | Starts retaining the most recent records in a bounded ring. More...
|
| |
| void | disable_backtrace () noexcept |
| | Stops backtrace capture and discards retained records. More...
|
| |
| void | dump_backtrace (const ConsoleWriter &console_writer) noexcept |
| | Writes retained records to the file and optional console callback. More...
|
| |
| bool | has_error () const noexcept |
| | Reports whether the running backend entered a permanent error state. More...
|
| |
| size_t | get_max_task_count () const override |
| | Returns the configured MessageLoop dispatcher queue capacity. More...
|
| |
| | MessageLoop () |
| | Constructs a loop with the default kNormalType queue. More...
|
| |
| | MessageLoop (Type type) |
| | Constructs a loop with the given queue type. More...
|
| |
| virtual | ~MessageLoop () |
| | Destructor; requests quit and joins the dispatcher thread if needed. More...
|
| |
| void | set_name (const std::string &name) |
| | Sets a human-readable name visible to profiling tools. More...
|
| |
| const std::string & | get_name () const |
| | Returns the loop name set via set_name. More...
|
| |
| Type | get_type () const |
| | Returns the queue type this loop was constructed with. More...
|
| |
| Strategy | get_strategy () const |
| | Returns the active back-pressure strategy. More...
|
| |
| void | set_strategy (Strategy strategy) |
| | Replaces the back-pressure strategy. More...
|
| |
| void | register_begin_handler (Callback &&callback) |
| | Registers a callback fired once at loop thread startup. More...
|
| |
| void | register_end_handler (Callback &&callback) |
| | Registers a callback fired once when the loop thread exits. More...
|
| |
| void | register_idle_handler (Callback &&callback) |
| | Registers a callback fired every time the queue becomes empty. More...
|
| |
| bool | run () |
| | Runs the loop on the calling thread until quit is requested. More...
|
| |
| bool | async_run () |
| | Starts the loop on a new background thread. More...
|
| |
| bool | spin () |
| | Alias of run blocking the calling thread. More...
|
| |
| bool | spin_once (bool block=true) |
| | Processes one batch of pending tasks and timers on the calling thread. More...
|
| |
| bool | quit (bool force=false) |
| | Requests the loop to exit. More...
|
| |
| bool | wait_for_quit (int ms=Timer::kInfinite, bool check=true) |
| | Waits until the loop has fully exited. More...
|
| |
| bool | post_task (Callback &&callback) |
| | Posts a task for execution on the loop thread. More...
|
| |
| TaskHandle | post_task_handle (Callback &&callback, const PostTaskOptions &options={}) |
| | Tracked variant of post_task returning a TaskHandle. More...
|
| |
| bool | post_task_with_priority (Callback &&callback, uint16_t priority) |
| | Posts a task with an explicit priority on a kPriorityType loop. More...
|
| |
| TaskHandle | post_task_with_priority_handle (Callback &&callback, uint16_t priority, const PostTaskOptions &options={}) |
| | Tracked variant of post_task_with_priority returning a TaskHandle. More...
|
| |
| template<typename CallbackT , typename = std::enable_if_t<!std::is_convertible_v<CallbackT, Schedule::RetCallback>>> |
| Schedule::Status | exec_task (const Schedule::Config &config, CallbackT &&callback) |
| | Schedules a void-returning callable and returns a chainable Schedule::Status. More...
|
| |
| template<typename CallbackT , typename = std::enable_if_t<std::is_convertible_v<CallbackT, Schedule::RetCallback>>> |
| Schedule::RetStatus | exec_task (const Schedule::Config &config, CallbackT &&callback) |
| | Schedules a bool-returning callable and returns a chainable Schedule::RetStatus. More...
|
| |
| bool | wakeup () |
| | Wakes the loop thread if it is suspended in its idle wait. More...
|
| |
| void | reset_lockfree_capacity () |
| | Recreates the lock-free queue, clearing all queued tasks and counters. More...
|
| |
| bool | is_running () const |
| | Reports whether the loop is currently running. More...
|
| |
| bool | is_ready_to_quit () const |
| | Reports whether quit has been requested and the loop is winding down. More...
|
| |
| bool | is_busy () const |
| | Reports whether the loop is currently executing a task. More...
|
| |
| size_t | get_task_count () const |
| | Returns the current pending task count. More...
|
| |
| virtual bool | wait_for_idle (int ms=Timer::kInfinite, bool check=true) |
| | Waits until the loop has drained its queue and is not executing a task. More...
|
| |
| virtual size_t | get_max_timer_count () const |
| | Returns the maximum number of timers that can be attached. More...
|
| |
| virtual uint32_t | get_max_elapsed_time () const |
| | Returns the maximum allowed task execution time in milliseconds. More...
|
| |
| virtual bool | is_in_same_thread () const |
| | Reports whether the calling thread is owned by this loop. More...
|
| |
| std::shared_ptr< AliveState > | get_alive_state () const |
| | Returns the shared lifetime flag used by cross-thread bridges. More...
|
| |
| template<class FunctionT , class... ArgsT> |
| auto | invoke_task (FunctionT &&function, ArgsT &&... args) |
| | Dispatches a callable to the loop thread and returns a std::future for the result. More...
|
| |
| template<class FunctionT , class... ArgsT> |
| auto | invoke_task_with_priority (FunctionT &&function, uint16_t priority, ArgsT &&... args) |
| | Priority variant of invoke_task; requires a kPriorityType loop. More...
|
| |
MessageLoop-based asynchronous rotating-file backend.
Each accepted record owns its message until a single worker thread formats and writes it. Queue overflow either blocks producers or discards an older record from the dispatcher queue according to Config::block_when_full; Error and Fatal records always block and remain protected. Low-frequency control operations use protected queue barriers, so flush and backtrace changes cannot be evicted by data-plane overflow.
- Note
- A backend must exclusively own its rotating-file set. Separate processes or backend instances should use separate paths. Flush transfers buffered bytes to the operating system but does not provide power-loss durability equivalent to
fsync.
-
Stop and join all callers before destruction. Inherited
MessageLoop lifecycle controls may be used to stop the worker for diagnostics, but a stopped backend must not be restarted; direct shutdown may discard records that have not reached the worker batch.