|
|
| simple_worker (const simple_worker &)=delete |
| | Copy constructor (deleted - workers are not copyable).
|
|
simple_worker & | operator= (const simple_worker &)=delete |
| | Copy assignment operator (deleted - workers are not copyable).
|
| | ~simple_worker () |
| | Destructor - gracefully shuts down the worker thread.
|
| bool | shutdown (std::chrono::milliseconds timeout=DEFAULT_SHUTDOWN_DRAIN_MS) |
|
| simple_worker (simple_worker &&)=delete |
| | Move constructor (deleted - workers are not movable).
|
|
simple_worker & | operator= (simple_worker &&)=delete |
| | Move assignment operator (deleted - workers are not movable).
|
| | simple_worker (std::function< void(T &&)> c) |
| | Constructs a worker thread with the given callback.
|
| void | queue (T &&item) noexcept(false) |
| | Queue a work item for processing.
|
template<typename T, int Pri = 0>
requires ((Pri >= -10) && (Pri <= 10)) && std::move_constructible<T>
struct siddiqsoft::simple_worker< T, Pri >
- Examples
- /opt/azure-agent/_work/18/s/include/siddiqsoft/simple_worker.hpp.
Definition at line 105 of file simple_worker.hpp.
◆ ~simple_worker()
template<typename T, int Pri = 0>
◆ simple_worker()
template<typename T, int Pri = 0>
Constructs a worker thread with the given callback.
Creates a single worker thread that will process items from the queue using the provided callback function.
- Parameters
-
| c | The worker callback function with signature void(T&&) Called for each item dequeued from the worker's queue |
- The callback is stored and invoked by the worker thread
- The worker thread starts immediately and waits for items
- Thread priority is set if Pri != 0 (Windows only)
- Exceptions in callbacks are caught and logged to prevent thread termination
Definition at line 212 of file simple_worker.hpp.
◆ queue()
template<typename T, int Pri = 0>
Queue a work item for processing.
Adds an item to the worker's queue for asynchronous processing. The worker thread will process this item as soon as it becomes available.
- Parameters
-
| item | The work item to queue (must be move-constructible) Ownership is transferred to the worker |
- Thread-safe operation
- Increments the queue counter with release semantics
- Item is moved into the internal queue
- Worker thread is signaled to wake up if waiting
- Note
- The item is moved into the queue, so the original is no longer valid
- Examples
- /opt/azure-agent/_work/18/s/include/siddiqsoft/simple_worker.hpp.
Definition at line 235 of file simple_worker.hpp.
◆ shutdown()
template<typename T, int Pri = 0>
◆ accepting_items
template<typename T, int Pri = 0>
◆ DEFAULT_SHUTDOWN_DRAIN_MS
template<typename T, int Pri = 0>
◆ DEFAULT_WAIT_FOR_NEXT_ITEM_MS
template<typename T, int Pri = 0>
◆ shutdown_initiated
template<typename T, int Pri = 0>
◆ shutdown_invoked
template<typename T, int Pri = 0>
The documentation for this struct was generated from the following file: