10
10
11
11
use time:: Duration ;
12
12
use sys_common:: mutex:: { self , Mutex } ;
13
- use sys :: condvar as imp ;
13
+ use sys_common :: parking_lot :: condvar:: Condvar as RawCondvar ;
14
14
15
15
/// An OS-based condition variable.
16
16
///
17
17
/// This structure is the lowest layer possible on top of the OS-provided
18
18
/// condition variables. It is consequently entirely unsafe to use. It is
19
19
/// recommended to use the safer types at the top level of this crate instead of
20
20
/// this type.
21
- pub struct Condvar ( imp :: Condvar ) ;
21
+ pub struct Condvar ( RawCondvar ) ;
22
22
23
23
impl Condvar {
24
24
/// Creates a new condition variable for use.
25
25
///
26
26
/// Behavior is undefined if the condition variable is moved after it is
27
27
/// first used with any of the functions below.
28
28
#[ unstable( feature = "sys_internals" , issue = "0" ) ] // FIXME: min_const_fn
29
- pub const fn new ( ) -> Condvar { Condvar ( imp :: Condvar :: new ( ) ) }
29
+ pub const fn new ( ) -> Condvar { Condvar ( RawCondvar :: new ( ) ) }
30
30
31
31
/// Prepares the condition variable for use.
32
32
///
33
33
/// This should be called once the condition variable is at a stable memory
34
34
/// address.
35
35
#[ inline]
36
- pub unsafe fn init ( & mut self ) { self . 0 . init ( ) }
36
+ pub unsafe fn init ( & mut self ) { }
37
37
38
38
/// Signals one waiter on this condition variable to wake up.
39
39
#[ inline]
40
- pub unsafe fn notify_one ( & self ) { self . 0 . notify_one ( ) }
40
+ pub unsafe fn notify_one ( & self ) { self . 0 . notify_one ( ) ; }
41
41
42
42
/// Awakens all current waiters on this condition variable.
43
43
#[ inline]
44
- pub unsafe fn notify_all ( & self ) { self . 0 . notify_all ( ) }
44
+ pub unsafe fn notify_all ( & self ) { self . 0 . notify_all ( ) ; }
45
45
46
46
/// Waits for a signal on the specified mutex.
47
47
///
@@ -59,13 +59,13 @@ impl Condvar {
59
59
/// on this condition variable.
60
60
#[ inline]
61
61
pub unsafe fn wait_timeout ( & self , mutex : & Mutex , dur : Duration ) -> bool {
62
- self . 0 . wait_timeout ( mutex:: raw ( mutex) , dur)
62
+ ! self . 0 . wait_for ( mutex:: raw ( mutex) , dur) . timed_out ( )
63
63
}
64
64
65
65
/// Deallocates all resources associated with this condition variable.
66
66
///
67
67
/// Behavior is undefined if there are current or will be future users of
68
68
/// this condition variable.
69
69
#[ inline]
70
- pub unsafe fn destroy ( & self ) { self . 0 . destroy ( ) }
70
+ pub unsafe fn destroy ( & self ) { }
71
71
}
0 commit comments