I am trying to develop a concurrent queue using POSIX threads + C++ with the following semantics:
- Some threads may call push(item, timeout) and if the addition of the element does not happen by time timeout it must be rejected.
- Some threads may call pop(item, timeout) and again if deletion of the element does not happen by time timeout it must be rejected.
- Some threads will always call push(item) and pop(item) which means that these always get done -- no bounds on time is specified.
My questions:
- I believe it makes sense to prioritize the threads that have timeouts. So I am using pthread scheduling to allocate higher priority to threads that have timeouts. Is this the only approach I can take?
- Despite the altering of thread priorities some threads with timeouts have to be rejected. How to keep these at a minimum?