MEDIUM: poller: separate the wait time from the wake events
We have been abusing the do_poll()'s timeout for a while, making it zero
whenever there is some known activity. The problem this poses is that it
complicates activity diagnostic by incrementing the poll_exp field for
each known activity. It also requires extra computations that could be
avoided.
This change passes a "wake" argument to say that the poller must not
sleep. This simplifies the operations and allows one to differenciate
expirations from activity.
diff --git a/include/types/fd.h b/include/types/fd.h
index 3ff4f65..9b54553 100644
--- a/include/types/fd.h
+++ b/include/types/fd.h
@@ -142,7 +142,7 @@
* - <private> is initialized by the poller's init() function, and cleaned by
* the term() function.
* - clo() should be used to do indicate the poller that fd will be closed.
- * - poll() calls the poller, expiring at <exp>
+ * - poll() calls the poller, expiring at <exp>, or immediately if <wake> is set
* - flags indicate what the poller supports (HAP_POLL_F_*)
*/
@@ -151,7 +151,7 @@
struct poller {
void *private; /* any private data for the poller */
void REGPRM1 (*clo)(const int fd); /* mark <fd> as closed */
- void REGPRM2 (*poll)(struct poller *p, int exp); /* the poller itself */
+ void REGPRM3 (*poll)(struct poller *p, int exp, int wake); /* the poller itself */
int REGPRM1 (*init)(struct poller *p); /* poller initialization */
void REGPRM1 (*term)(struct poller *p); /* termination of this poller */
int REGPRM1 (*test)(struct poller *p); /* pre-init check of the poller */