From 6385e2d41b99e4d527ddbeff558e22490527c4b5 Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Mon, 3 Nov 2014 14:44:05 -0800 Subject: Make running actors event-driven Instead of waking up frequently to check if actors need to run, set an alarm for the first timeout and use a signalfd to get us out of poll() when the alarm expires and SIGALRM is sent. alarm(2) only has second granularity but we are using delayed actors for multi-second timeout handling so this is ok. All callsites were multiplying by 1000 for wait-in-msec, so just change actor_timer() callsites to pass timeout in seconds. Fold actor_check() into actor_poll(). Remove actor_timer_mod, not used. Rename actor_list to ready_list for clarity. Remove poll_list, no longer needed. Remove ACTOR_POLL_WAITING state, no longer needed. Add some more helpful macros to list.h. Based on earlier work by Chris Leech. Signed-off-by: Andy Grover --- include/list.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/list.h b/include/list.h index cccc3c3..94ad99b 100644 --- a/include/list.h +++ b/include/list.h @@ -38,6 +38,12 @@ static inline int list_empty(const struct list_head *head) #define list_entry(ptr, type, member) \ list_container_of(ptr, type, member) +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->next, type, member) + +#define list_first_entry_or_null(ptr, type, member) \ + (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) + #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) -- cgit v1.2.1