Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
async_worker.h File Reference

Standalone async worker implementation with jthread compatibility kcenon. More...

#include "jthread_compat.h"
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
#include <memory>
#include <mutex>
#include <queue>
#include <thread>
Include dependency graph for async_worker.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  kcenon::logger::async::async_worker
 Standalone async worker with jthread compatibility. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::logger
 
namespace  kcenon::logger::async
 

Typedefs

using kcenon::logger::async::task_type = std::function<void()>
 Task type for async worker.
 

Detailed Description

Standalone async worker implementation with jthread compatibility kcenon.

Since
1.3.0

This file provides a standalone async worker that uses std::jthread for cooperative cancellation support where available, with a fallback to std::thread + manual stop mechanism for environments without jthread support (e.g., libc++ on macOS/Clang).

Key features:

  • std::jthread with std::stop_token for graceful shutdown (when available)
  • Fallback to std::thread with manual stop signaling (for libc++)
  • Lock-free queue for high-throughput message passing
  • Configurable queue size and batch processing
  • Cooperative cancellation without blocking operations
Note
Part of Issue #222: Remove thread_system dependency

Definition in file async_worker.h.