I am wondering if the following concept is known as a programming pattern.
Imagine a worker queue, but instead of each queue entry beeing removed when processed, it should be removed when another thread has catched the remove-event or when a remove-event was triggered.
So it would go like this:
- command gets into the queue
- 2nd command gets into the queue
- 3rd …
- first command gets processed
- first command waits to be removed
- 2nd command gets processed
- remove-event for first command was fired
- first command gets removed
- 2nd command waits to be removed
- …
I hope, I made this clear enough to understand.
Now is there a boost library, which has implemented such behaviour? Is there a pattern representing this behaviour?
As far as I can see, you’re just talking about two queues – the “novel” one being the queue of pending removals. Standard queues (deque) should be fine. You’d need a mutex, and a condition variable to signal the removal events. Wanting a name for such a pattern is a bit gradiose (people expect that too much these days)… if I were describing it I might say we have a decoupled removal thread (assuming that’s how you implement it), an asynchronous removal process (similarly), or even delayed element removal (which is true even if not done in a separate thread).