7 virtual void callback_run() = 0;
9 void callback_enqueue();
35 template<
typename t_
class,
typename t_param1,
typename t_param2>
static void main_thread_callback_spawn(
const t_param1 & p1,
const t_param2 & p2) {
42 template<
typename host_t,
typename param_t>
43 static void callThis(host_t * host, param_t & param) {
44 host->inMainThread(param);
46 template<
typename host_t>
53 template<
typename service_t,
typename param_t>
68 template<
typename myservice_t,
typename param_t>
87 typedef std::function< void () >
func_t;
93 entryFunc( func_t
const & func, killswitch_t ks ) : m_ks(ks), m_func(func) {}
104 template<
typename host_t,
typename arg_t>
107 entry( host_t * host, arg_t
const & arg, killswitch_t ks ) : m_ks(ks), m_host(host), m_arg(arg) {}
116 template<
typename host_t>
119 entryVoid( host_t * host, killswitch_t ks ) : m_ks(ks), m_host(host) {}
132 template<
typename host_t,
typename arg_t>
133 void add( host_t * host, arg_t
const & arg) {
136 template<
typename host_t>
137 void add( host_t * host ) {
140 void add_( main_thread_callback::ptr cb ) {
void add_(main_thread_callback::ptr cb)
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
void main_thread_callback_add(main_thread_callback::ptr ptr)
static void callThis(host_t *host, param_t ¶m)
void add(host_t *host, arg_t const &arg)
pfc::rcptr_t< bool > killswitch_t
entryVoid(host_t *host, killswitch_t ks)
entryFunc(func_t const &func, killswitch_t ks)
void callback_run()
Gets called from main app thread. See main_thread_callback_manager description for more info...
_callInMainThreadSvc_t(service_t *host, param_t const ¶m)
void inMainThread(std::function< void() > f)
void callback_run()
Gets called from main app thread. See main_thread_callback_manager description for more info...
entry(host_t *host, arg_t const &arg, killswitch_t ks)
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
void callback_run()
Gets called from main app thread. See main_thread_callback_manager description for more info...
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
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.
static void callInMainThreadSvc(myservice_t *host, param_t const ¶m)
~callInMainThreadHelper()
bool is_main_thread()
Returns true if calling thread is main app thread, false otherwise.
service_ptr_t< service_t > m_host
void callback_run()
Gets called from main app thread. See main_thread_callback_manager description for more info...
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
static void main_thread_callback_spawn()
std::function< void() > func_t
static void callThis(host_t *host)
Callback object class for main_thread_callback_manager service.