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

Utility class to help running a "pthread"-like thread in the main executor. More...

#include <test_main.hxx>

Inheritance diagram for ExecuteOnMainExecutor:
Executable Notifiable QMember Destructable

Public Types

typedef void * thread_fn_t(void *)
 Function type for a thread's main entry point.
 

Public Member Functions

 ExecuteOnMainExecutor (thread_fn_t *fn, void *arg)
 Schedules the function fn with argument arg on the main executor.
 
void run () OVERRIDE
 Runs the intended function with the given argument and then deletes this when done.
 
- 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.
 

Private Attributes

thread_fn_tfn_
 pointer to function to run.
 
void * arg_
 argument to pass to function.
 

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

Utility class to help running a "pthread"-like thread in the main executor.

Helpful for emscripten compatibility.

Definition at line 145 of file test_main.hxx.

Member Typedef Documentation

◆ thread_fn_t

typedef void * ExecuteOnMainExecutor::thread_fn_t(void *)

Function type for a thread's main entry point.

Definition at line 148 of file test_main.hxx.

Constructor & Destructor Documentation

◆ ExecuteOnMainExecutor()

ExecuteOnMainExecutor::ExecuteOnMainExecutor ( thread_fn_t fn,
void *  arg 
)
inline

Schedules the function fn with argument arg on the main executor.

Takes ownership of *this.

Parameters
fnis the entry function of the "thread".
argis the argument to pass to the function.

Definition at line 152 of file test_main.hxx.

Member Function Documentation

◆ run()

void ExecuteOnMainExecutor::run ( )
inlinevirtual

Runs the intended function with the given argument and then deletes this when done.

Implements Executable.

Definition at line 159 of file test_main.hxx.

Member Data Documentation

◆ arg_

void* ExecuteOnMainExecutor::arg_
private

argument to pass to function.

Definition at line 165 of file test_main.hxx.

◆ fn_

thread_fn_t* ExecuteOnMainExecutor::fn_
private

pointer to function to run.

Definition at line 164 of file test_main.hxx.


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