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

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

#include <CeresEngine/Platform/Apple/AppleRunLoop.hpp>

Inheritance diagram for CeresEngine::AppleRunLoop:
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

 AppleRunLoop () noexcept
 Creates a new Apple run loop instance for the current thread.
 
 AppleRunLoop (CFRunLoopRef runLoop) noexcept
 Creates a new Apple run loop from an existing CFRunLoopRef object.
 
 ~AppleRunLoop () 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.
 
CFRunLoopRef getRunLoop () const noexcept
 The CoreFoundation CFRunLoop instance to execute commands on.
 
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

CFRunLoopRef mRunLoop
 The CoreFoundation CFRunLoop instance to execute commands on.
 
CFRunLoopObserverRef mRunLoopObserver
 An observer that will receive events during the run loop execution.
 
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

◆ AppleRunLoop() [1/2]

CeresEngine::AppleRunLoop::AppleRunLoop ( )
explicitnoexcept

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

◆ AppleRunLoop() [2/2]

CeresEngine::AppleRunLoop::AppleRunLoop ( CFRunLoopRef  runLoop)
explicitnoexcept

Creates a new Apple run loop from an existing CFRunLoopRef object.

◆ ~AppleRunLoop()

CeresEngine::AppleRunLoop::~AppleRunLoop ( )
overridenoexcept

Destructor shuts down all threads in the system thread pool.

Member Function Documentation

◆ get_executor()

executor_type CeresEngine::AppleRunLoop::get_executor ( )
inlinenoexcept

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

◆ getExecutor()

AnyExecutor CeresEngine::AppleRunLoop::getExecutor ( )
finalvirtualnoexcept

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

Implements CeresEngine::ExecutionContext.

◆ getRunLoop()

CFRunLoopRef CeresEngine::AppleRunLoop::getRunLoop ( ) const
inlinenoexcept

The CoreFoundation CFRunLoop instance to execute commands on.

◆ onWorkFinished()

void CeresEngine::AppleRunLoop::onWorkFinished ( )
privatenoexcept

Inform the executor that some work is no longer outstanding.

◆ onWorkStarted()

void CeresEngine::AppleRunLoop::onWorkStarted ( )
privatenoexcept

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

◆ run()

void CeresEngine::AppleRunLoop::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::AppleRunLoop::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::AppleRunLoop::stop ( )
finalvirtual

Stops the execution of the run loop.

Note
This can be called from any thread.

Implements CeresEngine::RunLoop.

Member Data Documentation

◆ mRunLoop

CFRunLoopRef CeresEngine::AppleRunLoop::mRunLoop
private

The CoreFoundation CFRunLoop instance to execute commands on.

◆ mRunLoopObserver

CFRunLoopObserverRef CeresEngine::AppleRunLoop::mRunLoopObserver
private

An observer that will receive events during the run loop execution.

◆ mScope

Scope CeresEngine::AppleRunLoop::mScope
private

A scope for the run loop object.


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