concurrent_queue and blocking pop RRS feed

  • Question


     I am uing win32 Concurrency::concurrent_queue so that multiple threads can write to a queue and I need a single dedicated thread for reading.

     But there seems to be no blocking pop function. there only is try_block.

     how can implement blocking pop with this??

    Shahid Roofi

    Monday, December 30, 2019 5:58 PM


  •    well ended up dropping concurrent_queue usage at all. you have to use the while(1) is background thread to keep checking if queue have something which is very inefficient and will shoot your CPU to 100% for that thread all the time!!! waste.

       there is queue called MessagePump in Win32 which can be easily attached to the thread without window. It calls you back when message is available and also in all thread safe. 

      Ended up using that and it working fine …

      These datastructures of Concurrency:: are nice to play with but lack lot of work and support from the OS for their mainstream usage.

    Shahid Roofi

    • Marked as answer by Shahid Roofi Tuesday, December 31, 2019 10:00 PM
    Tuesday, December 31, 2019 10:00 PM