diff options
Diffstat (limited to 'iothread.h')
-rw-r--r-- | iothread.h | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -28,11 +28,28 @@ void iothread_service_completion(void); /** Waits for all iothreads to terminate. */ void iothread_drain_all(void); -/** Helper template */ +/** Performs a function on the main thread, blocking until it completes */ +int iothread_perform_on_main_base(int (*handler)(void *), void *context); + +/** Helper templates */ template<typename T> int iothread_perform(int (*handler)(T *), void (*completionCallback)(T *, int), T *context) { return iothread_perform_base((int (*)(void *))handler, (void (*)(void *, int))completionCallback, static_cast<void *>(context)); } +/* Variant that takes no completion callback */ +template<typename T> +int iothread_perform(int (*handler)(T *), T *context) +{ + return iothread_perform_base((int (*)(void *))handler, (void (*)(void *, int))0, static_cast<void *>(context)); +} + +template<typename T> +int iothread_perform_on_main(int (*handler)(T *), T *context) +{ + return iothread_perform_on_main_base((int (*)(void *))handler, (void *)(context)); +} + + #endif |