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

Abstracts a CoreFoundation CFRunLoop as an ASIO execution context. More...

#include <CeresEngine/Platform/Emscripten/EmscriptenRunLoop.hpp>

Inheritance diagram for CeresEngine::EmscriptenRunLoop:
CeresEngine::RunLoop CeresEngine::ExecutionContext

Classes

class  Executor
 An executor object that dispatches calls to the CoreFoundation CFRunLoop. More...
 

Public Types

using executor_type = Executor
 An executor object that dispatches calls to the CoreFoundation CFRunLoop.
 
- Public Types inherited from CeresEngine::ExecutionContext
using ID = id
 
using executor_type = AnyExecutor
 

Public Member Functions

 EmscriptenRunLoop () noexcept
 Creates a new emscripten run loop instance for the current thread.
 
 ~EmscriptenRunLoop () noexcept override
 Destructor shuts down all threads in the system thread pool.
 
AnyExecutor getExecutor () noexcept final
 Returns an executor that run execute scheduled commands on the context.
 
void stop () final
 Stops the execution of the run loop.
 
void run () final
 Starts running the run loop.
 
executor_type get_executor () noexcept
 Returns an executor that run execute scheduled commands on the context.
 
- Public Member Functions inherited from CeresEngine::RunLoop
 ~RunLoop () noexcept override=default
 Destroys the RunLoop.
 
- 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 Member Functions

void onWorkStarted () noexcept
 Inform the executor that it has some outstanding work to do.
 
void onWorkFinished () noexcept
 Inform the executor that some work is no longer outstanding.
 
void schedule (UniqueFunction< void()> function, ExecutorBlocking blockingProperty)
 Schedules a new function to be run in the run loop.
 

Private Attributes

pthread_t mThread
 The CoreFoundation CFRunLoop instance to execute commands on.
 
Scope mScope
 A scope for the run loop object.
 

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

Abstracts a CoreFoundation CFRunLoop as an ASIO execution context.

Member Typedef Documentation

◆ executor_type

An executor object that dispatches calls to the CoreFoundation CFRunLoop.

Constructor & Destructor Documentation

◆ EmscriptenRunLoop()

CeresEngine::EmscriptenRunLoop::EmscriptenRunLoop ( )
explicitnoexcept

Creates a new emscripten run loop instance for the current thread.

◆ ~EmscriptenRunLoop()

CeresEngine::EmscriptenRunLoop::~EmscriptenRunLoop ( )
overridenoexcept

Destructor shuts down all threads in the system thread pool.

Member Function Documentation

◆ get_executor()

executor_type CeresEngine::EmscriptenRunLoop::get_executor ( )
inlinenoexcept

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

◆ getExecutor()

AnyExecutor CeresEngine::EmscriptenRunLoop::getExecutor ( )
finalvirtualnoexcept

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

Implements CeresEngine::ExecutionContext.

◆ onWorkFinished()

void CeresEngine::EmscriptenRunLoop::onWorkFinished ( )
privatenoexcept

Inform the executor that some work is no longer outstanding.

◆ onWorkStarted()

void CeresEngine::EmscriptenRunLoop::onWorkStarted ( )
privatenoexcept

Inform the executor that it has some outstanding work to do.

◆ run()

void CeresEngine::EmscriptenRunLoop::run ( )
finalvirtual

Starts running the run loop.

Note
This can only be called from the thread that corresponds to the run loop execution.

Implements CeresEngine::RunLoop.

◆ schedule()

void CeresEngine::EmscriptenRunLoop::schedule ( UniqueFunction< void()>  function,
ExecutorBlocking  blockingProperty 
)
private

Schedules a new function to be run in the run loop.

Parameters
functionThe function to be executed.

◆ stop()

void CeresEngine::EmscriptenRunLoop::stop ( )
finalvirtual

Stops the execution of the run loop.

Note
This can be called from any thread.

Implements CeresEngine::RunLoop.

Member Data Documentation

◆ mScope

Scope CeresEngine::EmscriptenRunLoop::mScope
private

A scope for the run loop object.

◆ mThread

pthread_t CeresEngine::EmscriptenRunLoop::mThread
private

The CoreFoundation CFRunLoop instance to execute commands on.


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