From bd80a482ee9e8cc7500e1d31625935f4902f78b8 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 23 Sep 2018 19:57:35 -0700 Subject: libpulp: make pulp_tick() delay result optional Sometimes it's inconvenient for the caller to do anything useful with the delay value and will simply be running another tick as soon as possible. I see no point in interfering with this usage by requiring the caller to store the variable it won't be making use of anyways. So make next_tick_delay_us optional; when NULL this will be ignored. --- src/pulp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pulp.c b/src/pulp.c index e472fb9..f57f077 100644 --- a/src/pulp.c +++ b/src/pulp.c @@ -410,7 +410,7 @@ static void pulp_schedule(pulp_t *pulp) /* Tick a pulp scheduler - runs fibers until all are idle/sleeping. * * An estimate of how much time may pass before the next tick should occur is - * stored in next_tick_delay_us. + * stored in next_tick_delay_us (if non-NULL). * * If pulp_exit() is called by a fiber, or no more fibers exist, the return * value is -1, and next_tick_delay_us is ignored. @@ -442,7 +442,8 @@ int pulp_tick(pulp_t *pulp, unsigned *next_tick_delay_us) if (!list_empty(&pulp->fibers.sleep)) { /* TODO: get delay from the sleep queue when it's a priority queue */ - *next_tick_delay_us = 333; + if (next_tick_delay_us) + *next_tick_delay_us = 333; return 1; } -- cgit v1.2.3