This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Issue: std::condition_variable can't use std::chrono::system_clock if _GLIBCXX_USE_CLOCK_MONOTONIC is defined because it requires pthread_condattr_setclock et. al. to be implemented somehow in the gthreads backend.
Solution A) put in the condattr pthreads functions into the gthreads backend.
Issues with A) how well do the pthread attribute classes map to
non-pthread threading systems? My guess... not very well.
Solution B) Don't use a monotonic clock. Issues with B) Currently if _GLIBCXX_USE_CLOCK_MONOTONIC there is no non-monotonic clock since system_clock uses CLOCK_MONOTONIC and monotonic_clock and high_resolution_clock are just typedef's.
This patch solves the issue with solution B.
If _GLIBCXX_USE_CLOCK_MONOTONIC is defined, monotonic_clock is a separate class instead of a typedef. system_clock only ever uses the clock_gettime(CLOCK_REALTIME,...), gettimeofday or std::time and never clock_gettime(CLOCK_MONOTONIC).
Thus, condition_variable can use system_clock as its internal clock and although its never monotonic, there's no need for pthread_condattr_setclock et. al. and it all just works :)
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |