I am writing a timer-based scheduler and wanted share my ideas and also get suggestions.

**The Idea:**

Inform an `X process` of certain requests to perform at timed-intervals. So if the `X process` needs to perform an action every Y seconds, it should receive a request indicating to perform the action every Y seconds. In addition, it's priority-based: if multiple requests have the same timeout expiry, the request with a highest priority is sent out first.

**My thoughts:**

- Create a posix timer with the specified expiry time for each request 
- Create a priority queue, into which a request message is written every time from within the timer callback (triggers every expiry time).
- Have a main thread that probably reads from a priority queue every certain seconds, and writes back the read value to a message queue which invokes the `X process`.


**Concerns:**

- If there are multiple requests with the same timeout, how do we ensure the requests are sent in the order of priorities? 

My idea is: In the main thread, block it on priority queue and as soon as it's populated from the timer callback, signal the thread to wake up and wait for 1 second before reading from a priority queue. 1 second assuming is long enough to ensure requests of the same priority are already written to a priority queue and when the main thread first reads the request of the highest priority.

Could this be a feasible solution?