foobar2000 SDK
2015-08-03
|
#include <main_thread_callback.h>
Data Structures | |
class | entry |
class | entryFunc |
class | entryVoid |
Public Types | |
typedef std::function< void() > | func_t |
typedef pfc::rcptr_t< bool > | killswitch_t |
Public Member Functions | |
callInMainThreadHelper () | |
~callInMainThreadHelper () | |
void | add (func_t f) |
template<typename host_t , typename arg_t > | |
void | add (host_t *host, arg_t const &arg) |
template<typename host_t > | |
void | add (host_t *host) |
void | add_ (main_thread_callback::ptr cb) |
void | shutdown () |
Private Attributes | |
killswitch_t | m_ks |
Helper class to call methods of your class (host class) in main thread with convenience.
Deals with the otherwise ugly scenario of your class becoming invalid while a method is queued.
Have this as a member of your class, then use m_mthelper.add( this, somearg ) ; to defer a call to this->inMainThread(somearg).
If your class becomes invalid before inMainThread is executed, the pending callback is discarded.
You can optionally call shutdown() to invalidate all pending callbacks early (in a destructor of your class - without waiting for callInMainThreadHelper destructor to do the job.
In order to let callInMainThreadHelper access your private methods, declare friend class callInMainThread.
Definition at line 84 of file main_thread_callback.h.
typedef std::function< void () > callInMainThreadHelper::func_t |
Definition at line 87 of file main_thread_callback.h.
typedef pfc::rcptr_t< bool > callInMainThreadHelper::killswitch_t |
Definition at line 89 of file main_thread_callback.h.
|
inline |
Definition at line 144 of file main_thread_callback.h.
|
inline |
Definition at line 152 of file main_thread_callback.h.
|
inline |
Definition at line 128 of file main_thread_callback.h.
|
inline |
Definition at line 133 of file main_thread_callback.h.
|
inline |
Definition at line 137 of file main_thread_callback.h.
|
inline |
Definition at line 140 of file main_thread_callback.h.
|
inline |
Definition at line 148 of file main_thread_callback.h.
|
private |
Definition at line 157 of file main_thread_callback.h.