diff options
author | wm4 <wm4@nowhere> | 2014-04-24 12:49:19 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-04-25 08:35:02 +0200 |
commit | 5c3dd6402a8454f9a0cf652216dc94ecb308ced3 (patch) | |
tree | 348da617d1e857ebaae195223dd5b4a3f9f1e7b3 /misc/dispatch.c | |
parent | 89a19aafd9d217bfd1b03376a2db33be7cdfd9ad (diff) | |
download | mpv-5c3dd6402a8454f9a0cf652216dc94ecb308ced3.tar.bz2 mpv-5c3dd6402a8454f9a0cf652216dc94ecb308ced3.tar.xz |
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.)
Diffstat (limited to 'misc/dispatch.c')
-rw-r--r-- | misc/dispatch.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |