I need to design a "wait-for-event-objects" thingy that could accept opaque event objects and able to block until one of them is signaled. It should work on MacOS/Linux/Windows. So for Linux/Windows everything is very nice:
CreateEvent
in my pseudo class and in the class that does the waiting call WaitForMultipleObjects
.eventfd()
with poll()/epoll()
and achieve the same.kqueue
and kevent
with EVFILT_USER
BUT the issue is that I can not trigger the event without knowing the queue/having added the event to a queue, which is not a problem on Windows/Linux where I can either set the event or write to the descriptor.My question is, are there any chances that I have missed something and I could actually use kevent
and trigger it somehow so that when later added to a queue it becomes signalled? I am not talking about writing user space code, which let's say knows that an event has been set without a queue and then just signal it upon addition to a queue, I know that I can do that, but I'd pretty much like to use OS kernel primitives if there are such. Of course this excerpt from the man page:
EVFILT_USER Establishes a user event identified by ident which is not associated with any kernel mechanism but is triggered by user level code.
kind of clears all hopes. Then a follow up question - is there any other MacOS kernel mechanism that behaves similar to events and eventfd()
?
You can use a pipe similarly to how you use eventfd()
on Linux.
You could also use a Mach port and EVFILT_MACHPORT
.