diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-11-27 16:04:12 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-11-27 16:04:30 -0800 |
commit | 9f986d8a8660193d5a716a65307adb3708f14a24 (patch) | |
tree | be45c18d5ce5e6f47cc775784a611f47f960b47c /iothread.h | |
parent | e0b78f7f2a0274e834b3d5bd73f89184fc47fe87 (diff) |
Implemented iothread_perform_on_main() to support background threads
scheduling work on main thread
Diffstat (limited to 'iothread.h')
-rw-r--r-- | iothread.h | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -28,11 +28,22 @@ 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)); } +/** Helper templates */ +template<typename T> +int iothread_perform_on_main(int (*handler)(T *), T *context) +{ + return iothread_perform_on_main_base((int (*)(void *))handler, static_cast<void *>(context)); +} + + #endif |