I need the following architecture:
scheduling-thread(S):
- push scheduling event to "schedule" queue, with `data` and a `deadline`
scheduler-thread:
- forever loop
- process scheduling events from the "schedule" queue
- push event to a "deadlines-met" queue when deadline is met
customer-thread(S):
- listen to "deadlines-met" queue
That is, the scheduler-thread receives data from scheduling-threads via the "schedule" queue, and pushes them to a "deadlines-met" queue whenever the deadline is met.
Clients listening on the "deadlines-met" queue will receive the events at the desired time.
I am worried that the implementation of scheduler-thread
can be complicated, since it needs to do two things:
- listen to the "schedule" queue, and prepare deadlines
- push events at the right moment to the "deadlines-met" queue
And both can not be done at the same time: that is, if I am waiting for a deadline to expire, I can not listen for new scheduling events, and if I am listening I can not wait for a deadline to expire.
How could I implement this scheduling thread? The easy alternative (sched module), would block my thread while waiting for deadlines to expire, so that I could not process new scheduling events.