aboutsummaryrefslogtreecommitdiffhomepage
path: root/misc
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2014-04-23 20:56:35 +0200
committerGravatar wm4 <wm4@nowhere>2014-04-23 21:16:52 +0200
commit26723b32a976308874c5456f3233123af57334e8 (patch)
treeda7a16ba59e479d6bdd3a06129aa9e6ab7d07cb1 /misc
parentcd10af4db6c30d25f88095eab2ce24df6a6c92df (diff)
dispatch: improve documentation comments
Diffstat (limited to 'misc')
-rw-r--r--misc/dispatch.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/misc/dispatch.c b/misc/dispatch.c
index a28360d16c..aca25ff86b 100644
--- a/misc/dispatch.c
+++ b/misc/dispatch.c
@@ -110,12 +110,12 @@ static void mp_dispatch_append(struct mp_dispatch_queue *queue,
queue->wakeup_fn(queue->wakeup_ctx);
}
-// Let the dispatch item process asynchronously. item->fn will be run in the
-// target thread's context, but note that mp_dispatch_enqueue() will usually
-// return long before that happens. It's up to the user to signal completion
-// of the callback. It's also up to the user to guarantee that the context
-// (fn_data) has correct lifetime, i.e. lives until the callback is run, and
-// is freed after that.
+// Enqueue a callback to run it on the target thread asynchronously. The target
+// thread will run fn(fn_data) as soon as it enter mp_dispatch_queue_process.
+// Note that mp_dispatch_enqueue() will usually return long before that happens.
+// It's up to the user to signal completion of the callback. It's also up to
+// the user to guarantee that the context fn_data has correct lifetime, i.e.
+// lives until the callback is run, and is freed after that.
void mp_dispatch_enqueue(struct mp_dispatch_queue *queue,
mp_dispatch_fn fn, void *fn_data)
{
@@ -144,8 +144,10 @@ void mp_dispatch_enqueue_autofree(struct mp_dispatch_queue *queue,
mp_dispatch_append(queue, item);
}
-// Run the dispatch item synchronously. item->fn will be run in the target
-// thread's context, and this function will wait until it's done.
+// Run fn(fn_data) on the target thread synchronously. This function enqueues
+// the callback and waits until the target thread is done doing this.
+// This is redundant to calling the function inside mp_dispatch_[un]lock(),
+// but can be helpful with code that relies on TLS (such as OpenGL).
void mp_dispatch_run(struct mp_dispatch_queue *queue,
mp_dispatch_fn fn, void *fn_data)
{