> On Apr 4, 2016, at 12:09 PM, Sterling Hughes <[email protected]> wrote: > > hi, > > On 4/4/16 11:59 AM, marko kiiskila wrote: >> >>> On Apr 4, 2016, at 11:33 AM, Sterling Hughes <[email protected]> wrote: >>> >>>> I don’t think the select() kind of mask is a good idea. eventq_XXX is more >>>> like kqueue() rather than select(). I don’t think there are that many >>>> places >>>> where you’d want to mask out some events and not others. Especially >>>> as this’ll mean that there will presumably will mean that events will get >>>> delivered out of order. >>>> >>> >>> Would you prefer that eventq_poll() poll multiple eventq and return when an >>> event is available on one of them, or there is a timeout? I can >>> understand wanting to preserve ordering on the queue, and things getting >>> confusing if app code isn't smart about this. >>> >>> However, I think it is a fairly common access mechanism to want to grab >>> only certain events from a queue. Imagine a case where you send a packet, >>> and you are waiting for a response, and you only want to pull events >>> related to response from the eventq, even if you have multiple events that >>> can run through that queue. I see two options for handling this neatly: >>> >>> 1- Have a mask, and only pull events off that queue which match the mask >>> 2- Have eventq_poll() take multiple event queues, so that you can poll >>> multiple queues at once. >>> >>> What do you think? >>> >> >> Converting an array of integers to bit mask in the caller, and doing the >> reverse >> in the callee is not too great. >> >> Option 2 sounds much, much better. >> > > OK, cool. > > So, this is the API I'm thinking of: > > struct os_event * > os_eventq_poll(struct os_eventq **evq, int n, os_time_t timo); > > Where evq is an array of eventq to poll, and n is the number of elements in > that array. timo represents the timeout in ticks, across all the eventqs. > > This function returns NULL on no events within timo, or the first available > event if not. timo can be OS_WAIT_FOREVER, if caller wishes to sleep until > an event becomes available. > > Sterling
+1
