This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
clock type in std::condition_variable
- From: Martin Häfner <martinhaefner at web dot de>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sat, 26 Jan 2013 21:20:25 +0100
- Subject: clock type in std::condition_variable
Hello,
I was investigating the implementation of the C++11 condition_variable
in concern of timed waits and it's not clear to me if one can switch
the underlying clock type like it is possible for e.g. pthread_cond_t.
For my business this is a very important feature. Let me explain: in
our systems the realtime clock starts at 0 (not battery backed) and
after getting a GPS signal it will be adjusted to the actual value.
Due to this jump it would be a major problem if timed waits (i.e.
wait_for() ) would use the realtime clock since we will get spurious
wakeups. Therefore, we normally switch to CLOCK_MONOTONIC if dealing
with timed waits (with timeout, not absolute time) via a call to
pthread_condattr_setclock. It seems to me that the new C++11
condition_variable does not allow this since the clock to be used for
wait_for() and wait_until() is a fixed typedef within the class
definition.
Now, can anybody tell me if I missed something or if this can be
considered to be a deficiency of the GNU implementation of the
libstdc++ or even of the new standard? Could I work around without
switching back to the native POSIX library?
Regards,
Martin