engine


Include "zab/engine.hpp"


The engine is the core object in ZAB which represents the framework. The engine is responsible for running the event loops, ordering events for execution, handling cross thread events, and providing both Signal Handling and asynchronous io through the event_loop.

The engine is constructed with engine::configs to configure it at runtime.


struct zab::engine::configs

Public Types

enum thread_option

Values:

enumerator kAny
enumerator kAtLeast
enumerator kExact

Public Members

uint16_t threads_ = 1
thread_option opt_ = kAtLeast
bool affinity_set_ = true
uint16_t affinity_offset_ = 0

class zab::engine

This class describes an engine for enabling access to an interface and providing an tagged_event loop to execute requests.

Public Functions

engine(configs _configs)

Constructs an engine.

engine(engine &&_move) = default

Engines are movable.

Parameters

_move – The engine to move

~engine() = default

Destroys the engine.

void set_worker_affinity(thread_t _thread_id) noexcept
inline signal_handler &get_signal_handler() noexcept

Provides direct access to the signal handler.

Returns

The Wngines signal handler.

inline event_loop &get_event_loop() noexcept

Provides direct access to the tagged_event loop.

Returns

The Wngines tagged_event loop.

inline event_loop &get_event_loop(thread_t _thread) noexcept
inline timer_service &get_timer() noexcept
inline timer_service &get_timer(thread_t _thread) noexcept
void execute(std::function<void()> _yielder, order_t _order, thread_t _thread) noexcept
void resume(tagged_event _handle) noexcept
void thread_resume(tagged_event _handle, thread_t _thread) noexcept
void delayed_resume(tagged_event _handle, order_t _order) noexcept
void delayed_resume(tagged_event _handle, order_t _order, thread_t _thread) noexcept
void start() noexcept
void stop() noexcept
inline uint16_t number_of_workers() const noexcept

Get the number of worker events.

Returns

ThWDe nubmer of worker events.

Public Static Functions

static uint16_t core_count() noexcept

Gets the number of cores for the device.

Returns

The number of cores.

static uint16_t validate(configs &_configs)
static inline thread_t current_id() noexcept

Get the ID of the thread running this function.

Returns kAnyThread if this thread is not an engine thread.

Returns

The thread id.

struct configs

Public Types

enum thread_option

Values:

enumerator kAny
enumerator kAtLeast
enumerator kExact

Public Members

uint16_t threads_ = 1
thread_option opt_ = kAtLeast
bool affinity_set_ = true
uint16_t affinity_offset_ = 0