event: Extract event_poll loops to event_poll_until macro

A pattern that is becoming common across the project is to poll for events until
a certain condition is true, optionally passing a timeout. To address this
scenario, the event_poll_until macro was created and the job/channel/input
modules were refactored to use it on their blocking functions.
This commit is contained in:
Thiago de Arruda
2014-10-20 10:39:54 -03:00
parent 264e0d872c
commit b527ac752f
5 changed files with 54 additions and 51 deletions

View File

@@ -203,11 +203,7 @@ Object channel_send_call(uint64_t id,
// Push the frame
ChannelCallFrame frame = {request_id, false, false, NIL};
kv_push(ChannelCallFrame *, channel->call_stack, &frame);
do {
event_poll(-1);
} while (!frame.returned);
event_poll_until(-1, frame.returned);
(void)kv_pop(channel->call_stack);
if (frame.errored) {