diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-09-23 19:57:35 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-09-23 19:57:35 -0700 |
commit | bd80a482ee9e8cc7500e1d31625935f4902f78b8 (patch) | |
tree | f5d021134351c34e3d5656709dd62242ddfc7276 /src/pulp.c | |
parent | 1fb94cc5ec1c0e3ef694b3204afa1500f65dc2f0 (diff) |
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.
Diffstat (limited to 'src/pulp.c')
-rw-r--r-- | src/pulp.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; } |