File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
crates/symmetric_executor/src Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 11use std:: {
22 ffi:: c_int,
3+ mem:: transmute,
34 sync:: { atomic:: AtomicU32 , Arc , Mutex } ,
45 time:: { Duration , SystemTime } ,
56} ;
@@ -65,6 +66,14 @@ impl symmetric_executor::GuestEventGenerator for EventGenerator {
6566 }
6667}
6768
69+ struct Executor {
70+ active_tasks : Vec < EventSubscription > ,
71+ }
72+
73+ static EXECUTOR : Mutex < Executor > = Mutex :: new ( Executor {
74+ active_tasks : Vec :: new ( ) ,
75+ } ) ;
76+
6877impl symmetric_executor:: Guest for Guest {
6978 type CallbackFunction = Ignore ;
7079 type CallbackData = Ignore ;
@@ -80,7 +89,11 @@ impl symmetric_executor::Guest for Guest {
8089 callback : symmetric_executor:: CallbackFunction ,
8190 data : symmetric_executor:: CallbackData ,
8291 ) -> ( ) {
83- todo ! ( )
92+ let mut subscr = unsafe { * ( trigger. take_handle ( ) as * mut EventSubscription ) } ;
93+ let cb: fn ( * mut ( ) ) -> CallbackState = unsafe { transmute ( callback. take_handle ( ) ) } ;
94+ // let data = data.take_handle() as *mut ();
95+ subscr. callback . replace ( ( cb, data) ) ;
96+ EXECUTOR . lock ( ) . unwrap ( ) . active_tasks . push ( subscr) ;
8497 }
8598}
8699
You can’t perform that action at this time.
0 commit comments