FOSSredder 0.5.0
Loading...
Searching...
No Matches
core::jobs::Scheduler Class Reference

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.

Detailed Description

Runs background tasks on a bounded worker queue.

Definition at line 55 of file Scheduler.h.

Member Typedef Documentation

◆ Task

using core::jobs::Scheduler::Task = std::function<void()>

Definition at line 57 of file Scheduler.h.

Constructor & Destructor Documentation

◆ Scheduler() [1/2]

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.

Parameters
workersNumber of worker threads to start.
queueCapacityMaximum number of pending tasks.
errorReporterReporter used for uncaught task exceptions.

Definition at line 43 of file Scheduler.cpp.

Here is the caller graph for this function:

◆ ~Scheduler()

core::jobs::Scheduler::~Scheduler ( )

Stop workers and destroy the scheduler.

Definition at line 56 of file Scheduler.cpp.

Here is the call graph for this function:

◆ Scheduler() [2/2]

core::jobs::Scheduler::Scheduler ( const Scheduler & )
delete

Copying a scheduler is disabled.

Here is the call graph for this function:

Member Function Documentation

◆ enqueue()

void core::jobs::Scheduler::enqueue ( Task t)

Enqueue a task, blocking when the queue is full.

Parameters
tTask to run on a worker thread.

Definition at line 85 of file Scheduler.cpp.

Here is the caller graph for this function:

◆ operator=()

Scheduler & core::jobs::Scheduler::operator= ( const Scheduler & )
delete

Copy-assigning a scheduler is disabled.

Returns
Reference to this scheduler.
Here is the call graph for this function:

◆ stop()

void core::jobs::Scheduler::stop ( )

Stop accepting new tasks and join all worker threads.

Definition at line 61 of file Scheduler.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: