Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
SyncExecutable Class Reference

An Executable that runs a callback on the executor and returns once the run is complete. More...

Inheritance diagram for SyncExecutable:
Executable Notifiable QMember Destructable

Public Member Functions

 SyncExecutable (ExecutorBase *e, std::function< void()> &&fn)
 
void run () OVERRIDE
 Entry point.
 
- Public Member Functions inherited from Executable
void test_deletion ()
 
void notify () override
 Crashes the program – everyone who is expecting notify calls must override this function.
 
virtual void alloc_result (QMember *item)
 Return the result of an alloc_async() from a memory Pool.
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Public Attributes

std::function< void()> fn_
 Callback to run.
 
SyncNotifiable n_
 Blocks the calling thread until the callback is done running.
 

Additional Inherited Members

- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

An Executable that runs a callback on the executor and returns once the run is complete.

Must not be created against the local executor (because that would deterministically deadlock).

Usage:

SyncExecutable(stack.executor(), [] { DoFooBar(); });

Definition at line 127 of file Executor.cxx.

Constructor & Destructor Documentation

◆ SyncExecutable()

SyncExecutable::SyncExecutable ( ExecutorBase e,
std::function< void()> &&  fn 
)
inline
Parameters
eis the executor on which to execute the callback
fnis the callback to execute. Caller should use std::move to get the callback in here.

Definition at line 133 of file Executor.cxx.

Member Function Documentation

◆ run()

void SyncExecutable::run ( )
inlinevirtual

Entry point.

This funciton will be called when *this gets scheduled on the CPU.

Implements Executable.

Definition at line 140 of file Executor.cxx.

Member Data Documentation

◆ fn_

std::function<void()> SyncExecutable::fn_

Callback to run.

Definition at line 146 of file Executor.cxx.

◆ n_

SyncNotifiable SyncExecutable::n_

Blocks the calling thread until the callback is done running.

Definition at line 148 of file Executor.cxx.


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