SPH
Classes | Namespaces | Macros | Typedefs | Functions
MainLoop.h File Reference

Posting events to be executed on main thread. More...

#include "objects/wrappers/Function.h"
#include <wx/event.h>

Go to the source code of this file.

Classes

class  MainLoopEvent
 Custom event holding a callback. More...
 

Namespaces

 Sph
 

Macros

#define MainLoopEventHandler(func)   wxEVENT_HANDLER_CAST(MainLoopEventFunction, func)
 

Typedefs

typedef void(wxEvtHandler::* MainLoopEventFunction) (Sph::MainLoopEvent &)
 

Functions

 wxDECLARE_EVENT (MAIN_LOOP_TYPE, Sph::MainLoopEvent)
 
void executeOnMainThread (const Function< void()> &function)
 Posts a callback to be executed on main thread. More...
 
template<typename Type , typename TFunctor >
void executeOnMainThread (const SharedPtr< Type > &ptr, TFunctor functor)
 Executes a callback in main thread, passing a shared pointer to given object as its argument. More...
 

Detailed Description

Posting events to be executed on main thread.

Author
Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
Date
2016-2021

Definition in file MainLoop.h.

Macro Definition Documentation

◆ MainLoopEventHandler

#define MainLoopEventHandler (   func)    wxEVENT_HANDLER_CAST(MainLoopEventFunction, func)

Definition at line 18 of file MainLoop.h.

Typedef Documentation

◆ MainLoopEventFunction

typedef void(wxEvtHandler::* MainLoopEventFunction) (Sph::MainLoopEvent &)

Definition at line 17 of file MainLoop.h.

Function Documentation

◆ executeOnMainThread() [1/2]

void executeOnMainThread ( const Function< void()> &  function)

Posts a callback to be executed on main thread.

The function does not wait for the callback to be executed. The callback is executed by wxWidget framework; that means the event loop must be running and there must be an event handler executing the callback.

Definition at line 8 of file MainLoop.cpp.

◆ executeOnMainThread() [2/2]

template<typename Type , typename TFunctor >
void executeOnMainThread ( const SharedPtr< Type > &  ptr,
TFunctor  functor 
)

Executes a callback in main thread, passing a shared pointer to given object as its argument.

The callback is only executed if the object referenced by the shared pointer is not expired, otherwise it is ignored.

Definition at line 60 of file MainLoop.h.

◆ wxDECLARE_EVENT()

wxDECLARE_EVENT ( MAIN_LOOP_TYPE  ,
Sph::MainLoopEvent   
)