1

Is there any queue size limit for the c++ conditional variable, that is how many threads can wait concurrently on the same conditional variable. Or it is a dynamic queue bounded only by the available memory?

kmdreko
  • 42,554
  • 6
  • 57
  • 106
pyang
  • 109
  • 7
  • Are you asking about [std::condition_variable](https://en.cppreference.com/w/cpp/thread/condition_variable)? There may be different implementation of that class, in which implementation are you interested in (specify the OS, compiler, etc.)? – KamilCuk Feb 23 '19 at 06:49
  • Yes std::condition_variable. I am talking about gcc 5.4 on Linux. Thank you. – pyang Feb 24 '19 at 22:04
  • Then look up the [implementation](https://github.com/gcc-mirror/gcc/blob/gcc-5_4_0-release/libstdc++-v3/src/c++11/condition_variable.cc) and [here](https://www.cs.auckland.ac.nz/references/c/libstdcpp-api/a01182_source.html). It is implemented using `pthread_cond_wait`. I believe it would be limited by the [maximum number of threads](https://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux), but I guess the memory will run out faster. – KamilCuk Feb 24 '19 at 22:41

0 Answers0