From fda0975cb75f439e74231b68afdc76ee754ae7ca Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 3 May 2018 13:59:12 -0700 Subject: libpulp: move expire_alarms() to pulp_tick() begin Expiring alarms of sleeping fibers in pulp_schedule() has the potential to prevent pulp_tick() from ever returning if there's always another fiber expiring @ schedule. In order to allow simple integration with external event loops, pulp_tick() is supposed to operate on what is essentially a slice of runnable fibers then immediately return control to the caller. --- src/pulp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pulp.c b/src/pulp.c index fdb95cd..179451e 100644 --- a/src/pulp.c +++ b/src/pulp.c @@ -269,8 +269,6 @@ static void pulp_schedule(pulp_t *pulp) assert(pulp); - expire_alarms(pulp); - current = pulp->current; pulp->current = NULL; @@ -296,6 +294,8 @@ int pulp_tick(pulp_t *pulp, unsigned *next_tick_delay_us) { assert(pulp); + expire_alarms(pulp); + swap_context(&pulp->caller_context, &pulp->schedule_context); if (pulp->exited) -- cgit v1.2.3