diff options
| author | bors <bors@rust-lang.org> | 2016-08-30 16:28:32 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-30 16:28:32 -0700 |
| commit | eac41469d778d18ae7bf38fa917ed0fe122f944b (patch) | |
| tree | 566d38ce5971d64222c2d3cd00499e2d666e66a8 /src/libstd/sys/common | |
| parent | 4473130f4e0a20278225251ea6a0400258b03180 (diff) | |
| parent | 59e5e0b2db2ab66f138044bde80c44c7f9391a00 (diff) | |
| download | rust-eac41469d778d18ae7bf38fa917ed0fe122f944b.tar.gz rust-eac41469d778d18ae7bf38fa917ed0fe122f944b.zip | |
Auto merge of #35048 - tmiasko:monotonic-wait-timeout, r=alexcrichton
Use monotonic time in condition variables. Configure condition variables to use monotonic time using pthread_condattr_setclock on systems where this is possible. This fixes the issue when thread waiting on condition variable is woken up too late when system time is moved backwards.
Diffstat (limited to 'src/libstd/sys/common')
| -rw-r--r-- | src/libstd/sys/common/condvar.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/sys/common/condvar.rs b/src/libstd/sys/common/condvar.rs index 33734a88cf3..b6f29dd5fc3 100644 --- a/src/libstd/sys/common/condvar.rs +++ b/src/libstd/sys/common/condvar.rs @@ -27,6 +27,13 @@ impl Condvar { /// first used with any of the functions below. pub const fn new() -> Condvar { Condvar(imp::Condvar::new()) } + /// Prepares the condition variable for use. + /// + /// This should be called once the condition variable is at a stable memory + /// address. + #[inline] + pub unsafe fn init(&mut self) { self.0.init() } + /// Signals one waiter on this condition variable to wake up. #[inline] pub unsafe fn notify_one(&self) { self.0.notify_one() } |
