This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [RFC] Add pthread_cond_timedwaitonclock_np


On Tuesday 07 July 2015 at 15:28:56 +0100, Szabolcs Nagy wrote:
> On 07/07/15 14:56, Mike Crowe wrote:
> > C++11's std::condition_variable::wait_until specifies the clock to be
> > used at the time of the wait and permits separate waits on the same
> > instance using different clocks.
> > 
> > Unfortunately pthread_cond_timedwait always uses the clock that was
> > specified (or defaulted) when pthread_cond_init was called. libstdc++'s
> > current implementation converts all waits to
> > std::chrono::system_clock (i.e. CLOCK_REALTIME) which can race against
> > the system clock changing.
> > 
> > Inventing a brand-new function pthread_cond_timedwaitonclock_np which
> > accepts both the clock and the time point as parameters is
> > straightforward and means that the C++11 standard behaviour can be
> > implemented in libstdc++ on Linux at least.
> > 
> 
> do you have a reference to the rationale that introduced this api to C++?

Not exactly. Here are some interesting links:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2999.html

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4486.html (search
for "887")

https://www.redhat.com/archives/posix-c++-wg/2009-July/msg00002.html
(search for "887")

https://github.com/cplusplus/LWG/blob/master/xml/issue0887.xml

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41861

It seems that even more work than I was previously aware of has been
invested in trying to solve this over the past six years or so. :(

Mike.


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