Multiple producers, single consumer

前端 未结 4 1006
时光取名叫无心
时光取名叫无心 2020-12-03 11:58

I have to develop a multithreaded application, where there will be multiple threads, each thread generates custom event log which need to be saved in queue (not Microsoft MS

4条回答
  •  情书的邮戳
    2020-12-03 12:22

    Multiple producers, single consumer is the easiest scenario for multi threaded queue communication. A thread-queue can be implemented as a combination of condition variable/mutex and a std::queue (add a cv if you want to handle queue full).

    The consumer waits on the cv while the queue is empty. the producers signal when adding to the queue (sending).

提交回复
热议问题