@@ -15,7 +15,7 @@ use lazy_static::lazy_static;
15
15
use tokio:: runtime:: Runtime ;
16
16
use std:: os:: fd:: AsRawFd ;
17
17
18
- use super :: borrow_unchecked;
18
+ use super :: { borrow_unchecked, printf } ;
19
19
20
20
lazy_static ! {
21
21
pub static ref RUNTIME : Runtime = Runtime :: new( ) . expect( "Could not allocate runtime" ) ;
@@ -87,7 +87,17 @@ impl EventLoop {
87
87
88
88
pub fn wakeup ( ) -> PhpResult < ( ) > {
89
89
EVENTLOOP . with_borrow_mut ( |c| {
90
- c. as_mut ( ) . unwrap ( ) . wakeup_internal ( )
90
+ let c = c. as_mut ( ) . unwrap ( ) ;
91
+
92
+ c. notify_receiver . read_exact ( & mut c. dummy ) . unwrap ( ) ;
93
+
94
+ for fiber_id in c. receiver . try_iter ( ) {
95
+ if let Some ( fiber) = c. fibers . get_index_mut ( fiber_id) {
96
+ fiber. object_mut ( ) . unwrap ( ) . try_call_method ( "resume" , vec ! [ ] ) ?;
97
+ c. fibers . remove_index ( fiber_id) ;
98
+ }
99
+ }
100
+ Ok ( ( ) )
91
101
} )
92
102
}
93
103
@@ -113,23 +123,4 @@ impl EventLoop {
113
123
get_current_suspension : Function :: try_from_method ( "\\ Revolt\\ EventLoop" , "getSuspension" ) . ok_or ( "\\ Revolt\\ EventLoop::getSuspension does not exist" ) ?,
114
124
} )
115
125
}
116
-
117
- fn wakeup_internal ( & mut self ) -> PhpResult < ( ) > {
118
- self . notify_receiver . read_exact ( & mut self . dummy ) . unwrap ( ) ;
119
-
120
- for fiber_id in self . receiver . try_iter ( ) {
121
- if let Some ( fiber) = self . fibers . get_index_mut ( fiber_id) {
122
- fiber. object_mut ( ) . unwrap ( ) . try_call_method ( "resume" , vec ! [ ] ) ?;
123
- self . fibers . remove_index ( fiber_id) ;
124
- }
125
- }
126
- Ok ( ( ) )
127
- }
128
- }
129
-
130
- impl Drop for EventLoop {
131
- fn drop ( & mut self ) {
132
- unsafe { libc:: close ( self . notify_receiver . as_raw_fd ( ) ) } ;
133
- unsafe { libc:: close ( self . notify_sender . as_raw_fd ( ) ) } ;
134
- }
135
126
}
0 commit comments