File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,14 @@ declare_TCFType!(CFRunLoop, CFRunLoopRef);
26
26
impl_TCFType ! ( CFRunLoop , CFRunLoopRef , CFRunLoopGetTypeID ) ;
27
27
impl_CFTypeDescription ! ( CFRunLoop ) ;
28
28
29
+ #[ derive( Copy , Clone , Debug , PartialEq ) ]
30
+ pub enum CFRunLoopRunResult {
31
+ Finished = 1 ,
32
+ Stopped = 2 ,
33
+ TimedOut = 3 ,
34
+ HandledSource = 4 ,
35
+ }
36
+
29
37
impl CFRunLoop {
30
38
pub fn get_current ( ) -> CFRunLoop {
31
39
unsafe {
@@ -47,6 +55,24 @@ impl CFRunLoop {
47
55
}
48
56
}
49
57
58
+ pub fn run_in_mode (
59
+ mode : CFStringRef ,
60
+ duration : std:: time:: Duration ,
61
+ return_after_source_handled : bool ,
62
+ ) -> CFRunLoopRunResult {
63
+ let seconds = duration. as_secs_f64 ( ) ;
64
+ let return_after_source_handled = if return_after_source_handled { 1 } else { 0 } ;
65
+
66
+ unsafe {
67
+ match CFRunLoopRunInMode ( mode, seconds, return_after_source_handled) {
68
+ 2 => CFRunLoopRunResult :: Stopped ,
69
+ 3 => CFRunLoopRunResult :: TimedOut ,
70
+ 4 => CFRunLoopRunResult :: HandledSource ,
71
+ _ => CFRunLoopRunResult :: Finished ,
72
+ }
73
+ }
74
+ }
75
+
50
76
pub fn stop ( & self ) {
51
77
unsafe {
52
78
CFRunLoopStop ( self . 0 ) ;
You can’t perform that action at this time.
0 commit comments