I am looking into Time driven events and I can't seem to figure out how to this would be done without using an excessive amount of CPU constantly.
array events;
events[1] = [id:1,time:1440589943,event:happend];
While(running)
{
loop over events
if(currentTime >= eventTime)
fireEvent()
}
This seems like the most basic event handler I can come up with but it would I think consume alot of CPU constantly without really doing anything really.
So the question basically is: How do time driven events in other any languages handle time driven events? Do they constantly check if one is ready to be fired? Do they use a clever scheduling mechanic?
Thanks in advance.