From 5c3dd6402a8454f9a0cf652216dc94ecb308ced3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 24 Apr 2014 12:49:19 +0200 Subject: dispatch: document some guarantees The here documented guarantee might simplify code using this mechanism a lot, because it becomes unnecessary to invent a separate mechanism to make the mp_dispatch_queue_process loop exit after processing a dispatch callback. (Instead, the dispatch callback can set a flag, and the caller of mp_dispatch_queue_process can check it.) --- misc/dispatch.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'misc') diff --git a/misc/dispatch.c b/misc/dispatch.c index 59b3dbc98a..74576ff469 100644 --- a/misc/dispatch.c +++ b/misc/dispatch.c @@ -169,6 +169,10 @@ void mp_dispatch_run(struct mp_dispatch_queue *queue, // function can be much higher if the suspending/locking functions are used, or // if executing the dispatch items takes time. On the other hand, this function // can return much earlier than the timeout due to sporadic wakeups. +// It is also guaranteed that if at least one queue item was processed, the +// function will return as soon as possible, ignoring the timeout. This +// simplifies users, such as re-checking conditions before waiting. (It will +// still process the remaining queue items, and wait for unsuspend.) void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout) { pthread_mutex_lock(&queue->lock); -- cgit v1.2.3