morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::exec::IExecutor Struct Referenceabstract

Abstract executor interface. More...

#include <executor.hpp>

Inheritance diagram for morph::exec::IExecutor:
morph::exec::MainThreadExecutor morph::exec::OwnerStrand morph::exec::ThreadPoolExecutor morph::qt::QtExecutor morph::testing::StepExecutor morph::tui::LoopExecutor

Public Member Functions

 IExecutor (const IExecutor &)=delete
IExecutor & operator= (const IExecutor &)=delete
 IExecutor (IExecutor &&)=delete
IExecutor & operator= (IExecutor &&)=delete
virtual void post (std::function< void()> task)=0
 Schedules task for asynchronous execution.
virtual bool isSerial () const noexcept
 Whether this executor runs one task at a time, each after the tasks posted before it: a strand, a GUI loop, a pumped MainThreadExecutor.
::core::async::IExecutor & coreExecutor () noexcept
 This executor as a core-cpp executor: the identity an core::async::ExecutorScope names.

Detailed Description

Abstract executor interface.

Concrete implementations decide where and when posted tasks run (thread pool, main thread, Qt event loop, …).

An executor is an identity, so it is neither copyable nor movable: it owns the core-cpp adapter (coreExecutor()) that holds a pointer back to it.

Definition at line 70 of file executor.hpp.

Member Function Documentation

◆ post()

virtual void morph::exec::IExecutor::post ( std::function< void()> task)
pure virtual

Schedules task for asynchronous execution.

Thread-safe. The task is invoked at some point after this call returns. Any exception thrown by the task is silently swallowed unless the implementation documents otherwise.

Parameters
taskCallable to execute.

Implemented in morph::exec::MainThreadExecutor, morph::exec::OwnerStrand, morph::exec::ThreadPoolExecutor, morph::qt::QtExecutor, morph::testing::StepExecutor, and morph::tui::LoopExecutor.

◆ isSerial()

virtual bool morph::exec::IExecutor::isSerial ( ) const
inlinenodiscardvirtualnoexcept

Whether this executor runs one task at a time, each after the tasks posted before it: a strand, a GUI loop, a pumped MainThreadExecutor.

What an owner must be: a component whose state is touched only in its owner's tasks needs those tasks never to overlap. A pool runs several at once, and the inline executor runs each wherever it is posted from.

Returns
true unless an override says otherwise.

Reimplemented in morph::exec::ThreadPoolExecutor.

Definition at line 94 of file executor.hpp.

◆ coreExecutor()

::core::async::IExecutor & morph::exec::IExecutor::coreExecutor ( )
inlinenodiscardnoexcept

This executor as a core-cpp executor: the identity an core::async::ExecutorScope names.

Returns
The adapter that posts every resumption through post(). The same object for the executor's whole life.

Definition at line 100 of file executor.hpp.


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