This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[v3] c++0x timed wait's in <condition_variable>


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 :)

Chris

Attachment: Changelog_cond_var.txt
Description: Text document

Attachment: cond_var.patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]