aboutsummaryrefslogtreecommitdiffhomepage
path: root/iothread.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-11-27 16:04:12 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-11-27 16:04:30 -0800
commit9f986d8a8660193d5a716a65307adb3708f14a24 (patch)
treebe45c18d5ce5e6f47cc775784a611f47f960b47c /iothread.h
parente0b78f7f2a0274e834b3d5bd73f89184fc47fe87 (diff)
Implemented iothread_perform_on_main() to support background threads
scheduling work on main thread
Diffstat (limited to 'iothread.h')
-rw-r--r--iothread.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/iothread.h b/iothread.h
index 88c4a430..ac328ace 100644
--- a/iothread.h
+++ b/iothread.h
@@ -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