Can i use boost::threadpool as a 'thread-safe queue'?
What I need is actually a thread-safe queue structure, where multiple clients keep dumping data into the queue and one working thread keeps processing and popping the queue
is there any well-established solution existing in STL or Boost?
I now think about using Boost::threadpool to do this. Simply set the number of parallel threads to be 1, the input parameter of task function is changed every time new message arrives from a client. Does this make sense, is there any limitation that I have not yet anticipated here?
In boost there is a message queue class, that is what you need: a thread-safe queue.
Message queues is a widely-used concept for interprocess communication. A message queue is thread-safe queue, which key feature is that it blocks on reading from empty queue and waits for data to appear in it. In that boost class, timed waits are also supported, as well as blocking the writer if the queue is full.