CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::ThreadPool Class Reference

The thread pool class is an execution context where functions are permitted to run on one of a fixed number of threads. More...

#include <CeresEngine/Foundation/Threading/ThreadPool.hpp>

Inheritance diagram for CeresEngine::ThreadPool:
CeresEngine::ExecutionContext

Public Types

using Executor = Super::executor_type
 
- Public Types inherited from CeresEngine::ExecutionContext
using ID = id
 
using executor_type = AnyExecutor
 

Public Member Functions

AnyExecutor getExecutor () noexcept override
 Returns an executor that run execute scheduled commands on the context.
 
- Public Member Functions inherited from CeresEngine::ExecutionContext
virtual ~ExecutionContext () noexcept=default
 Virtual destructor for the execution context object.
 
template<typename T >
bool hasService () noexcept
 Determine if the ExecutionContext contains the specified service type.
 
template<typename T >
TgetService () noexcept
 Obtain the service object corresponding to the given type.
 
template<typename T >
TgetServiceIf () noexcept
 Obtain the service object corresponding to the given type.
 
executor_type get_executor () noexcept
 Returns an executor that run execute scheduled commands on the context.
 
bool isActive () const noexcept
 Checks if the execution context is currently active.
 

Private Types

using Super = asio::thread_pool
 

Additional Inherited Members

- Static Public Member Functions inherited from CeresEngine::ExecutionContext
static ExecutionContextgetCurrent () noexcept
 Gets the current execution context, if any is active.
 
static ExecutionContextget () noexcept
 Gets the current execution context, if any is active.
 

Detailed Description

The thread pool class is an execution context where functions are permitted to run on one of a fixed number of threads.

tasks to the pool

To submit functions to the thread pool, use the dispatch(), post() or defer() free functions.

For example:

void myTask() { ... }
// Launch the pool with four threads.
// Submit a function to the pool.
post(pool, myTask);
// Submit a lambda object to the pool.
post(pool, []() { ... });
// Wait for all tasks in the pool to complete.
pool.join();
The thread pool class is an execution context where functions are permitted to run on one of a fixed ...
Definition ThreadPool.hpp:40
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25

Member Typedef Documentation

◆ Executor

using CeresEngine::ThreadPool::Executor = Super::executor_type

◆ Super

using CeresEngine::ThreadPool::Super = asio::thread_pool
private

Member Function Documentation

◆ getExecutor()

AnyExecutor CeresEngine::ThreadPool::getExecutor ( )
inlineoverridevirtualnoexcept

Returns an executor that run execute scheduled commands on the context.

Implements CeresEngine::ExecutionContext.


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