@@ -11,7 +11,7 @@ use std::collections::HashMap;
11
11
use std:: rc:: Rc ;
12
12
use wasi:: io:: poll:: Pollable ;
13
13
14
- #[ derive( Debug ) ]
14
+ #[ derive( Debug , PartialEq , Eq , Hash ) ]
15
15
struct Registration {
16
16
key : EventKey ,
17
17
}
@@ -22,25 +22,27 @@ impl Drop for Registration {
22
22
}
23
23
}
24
24
25
- #[ derive( Debug , Clone ) ]
25
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
26
26
pub struct AsyncPollable ( Rc < Registration > ) ;
27
27
28
28
impl AsyncPollable {
29
29
pub fn wait_for ( & self ) -> WaitFor {
30
30
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
31
31
static COUNTER : AtomicUsize = AtomicUsize :: new ( 0 ) ;
32
32
let unique = COUNTER . fetch_add ( 1 , Ordering :: Relaxed ) ;
33
- let key = self . 0 . key ;
34
33
WaitFor {
35
- waitee : Waitee { key, unique } ,
34
+ waitee : Waitee {
35
+ pollable : self . clone ( ) ,
36
+ unique,
37
+ } ,
36
38
needs_deregistration : false ,
37
39
}
38
40
}
39
41
}
40
42
41
43
#[ derive( Debug , PartialEq , Eq , Hash , Clone ) ]
42
44
struct Waitee {
43
- key : EventKey ,
45
+ pollable : AsyncPollable ,
44
46
unique : usize ,
45
47
}
46
48
@@ -125,7 +127,7 @@ impl Reactor {
125
127
let mut reactor = self . inner . borrow_mut ( ) ;
126
128
for key in reactor. poller . block_until ( ) {
127
129
for ( waitee, waker) in reactor. wakers . iter ( ) {
128
- if waitee. key == key {
130
+ if waitee. pollable . 0 . key == key {
129
131
waker. wake_by_ref ( )
130
132
}
131
133
}
@@ -156,7 +158,7 @@ impl Reactor {
156
158
let mut reactor = self . inner . borrow_mut ( ) ;
157
159
let ready = reactor
158
160
. poller
159
- . get ( & waitee. key )
161
+ . get ( & waitee. pollable . 0 . key )
160
162
. expect ( "only live EventKey can be checked for readiness" )
161
163
. ready ( ) ;
162
164
if !ready {
0 commit comments