|
FOSSredder 0.5.0
|
Runs background tasks on a bounded worker queue. More...
#include <Scheduler.h>
Public Types | |
| using | Task = std::function<void()> |
Public Member Functions | |
| Scheduler (std::size_t workers, std::size_t queueCapacity, std::shared_ptr< core::ports::diagnostics::IErrorReporter > errorReporter) | |
| Create a scheduler with bounded workers and queue capacity. | |
| ~Scheduler () | |
| Stop workers and destroy the scheduler. | |
| Scheduler (const Scheduler &)=delete | |
| Copying a scheduler is disabled. | |
| Scheduler & | operator= (const Scheduler &)=delete |
| Copy-assigning a scheduler is disabled. | |
| void | enqueue (Task t) |
| Enqueue a task, blocking when the queue is full. | |
| void | stop () |
| Stop accepting new tasks and join all worker threads. | |
Runs background tasks on a bounded worker queue.
Definition at line 55 of file Scheduler.h.
| using core::jobs::Scheduler::Task = std::function<void()> |
Definition at line 57 of file Scheduler.h.
| core::jobs::Scheduler::Scheduler | ( | std::size_t | workers, |
| std::size_t | queueCapacity, | ||
| std::shared_ptr< core::ports::diagnostics::IErrorReporter > | errorReporter ) |
Create a scheduler with bounded workers and queue capacity.
| workers | Number of worker threads to start. |
| queueCapacity | Maximum number of pending tasks. |
| errorReporter | Reporter used for uncaught task exceptions. |
Definition at line 43 of file Scheduler.cpp.

| core::jobs::Scheduler::~Scheduler | ( | ) |
Stop workers and destroy the scheduler.
Definition at line 56 of file Scheduler.cpp.

|
delete |
Copying a scheduler is disabled.

| void core::jobs::Scheduler::enqueue | ( | Task | t | ) |
Enqueue a task, blocking when the queue is full.
| t | Task to run on a worker thread. |
Definition at line 85 of file Scheduler.cpp.

Copy-assigning a scheduler is disabled.

| void core::jobs::Scheduler::stop | ( | ) |
Stop accepting new tasks and join all worker threads.
Definition at line 61 of file Scheduler.cpp.

