Queuing items with timeouts
I have an idea / feature request:
I often find myself in the situation when I want to put something in a queue for a while, i.e. give it a timestamp when the receiving task is able to retrieve the item. Often it may be the same task that has retrieved a command from a command queue but isn’t able to process it at that time (because something may be busy and we don’t want to wait for it), then it would be nice to stick it back in the queue but not have to deal with the problem that the task will just immediately fetch the item out of the queue again. Doing a forced delay before calling xQueueReceive is not always appropriate because the task might have other things to do.
The idea is that xQueueReceive blocks until an item in the queue times out and then it is returned. Note that unlike regular queues, the items would be returned in the order in which they time out – not in the order that they were posted. So, strictly speaking it wouldn’t really be a queue.
Just an idea but I can’t really figure out an elegant way of dealing with this situation without something like this.