aboutsummaryrefslogtreecommitdiffhomepage
path: root/iothread.h
diff options
context:
space:
mode:
Diffstat (limited to 'iothread.h')
-rw-r--r--iothread.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/iothread.h b/iothread.h
index 88c4a430..bdec2195 100644
--- a/iothread.h
+++ b/iothread.h
@@ -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