1
1
#![ no_std]
2
2
#![ doc = include_str ! ( "../README.md" ) ]
3
3
4
- use core:: sync:: atomic:: AtomicU32 ;
4
+ use core:: sync:: atomic:: { AtomicPtr , AtomicU32 } ;
5
5
6
6
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
7
7
#[ path = "linux.rs" ]
@@ -28,6 +28,14 @@ pub fn wait(atomic: &AtomicU32, value: u32) {
28
28
platform:: wait ( atomic, value)
29
29
}
30
30
31
+ /// If the value is `value`, wait until woken up.
32
+ ///
33
+ /// This function might also return spuriously,
34
+ /// without a corresponding wake operation.
35
+ pub fn wait_ptr < T > ( atomic : * const AtomicPtr < T > , value : * mut T ) {
36
+ platform:: wait_ptr ( atomic, value)
37
+ }
38
+
31
39
/// Wake one thread that is waiting on this atomic.
32
40
///
33
41
/// It's okay if the pointer dangles or is null.
@@ -36,10 +44,25 @@ pub fn wake_one(atomic: *const AtomicU32) {
36
44
platform:: wake_one ( atomic) ;
37
45
}
38
46
47
+ /// Wake one thread that is waiting on this atomic.
48
+ ///
49
+ /// It's okay if the pointer dangles or is null.
50
+ #[ inline]
51
+ pub fn wake_one_ptr < T > ( atomic : * const AtomicPtr < T > ) {
52
+ platform:: wake_one_ptr ( atomic) ;
53
+ }
54
+
39
55
/// Wake all threads that are waiting on this atomic.
40
56
///
41
57
/// It's okay if the pointer dangles or is null.
42
58
#[ inline]
43
59
pub fn wake_all ( atomic : * const AtomicU32 ) {
44
60
platform:: wake_all ( atomic) ;
45
61
}
62
+
63
+ /// Wake all threads that are waiting on this atomic.
64
+ ///
65
+ /// It's okay if the pointer dangles or is null.
66
+ pub fn wake_all_ptr < T > ( atomic : * const AtomicPtr < T > ) {
67
+ platform:: wake_all_ptr ( atomic) ;
68
+ }
0 commit comments