Skip to content

Commit dddc8cd

Browse files
committed
implement register (incomplete)
1 parent 4c19fbd commit dddc8cd

File tree

1 file changed

+14
-1
lines changed
  • crates/symmetric_executor/src

1 file changed

+14
-1
lines changed

crates/symmetric_executor/src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use 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+
6877
impl 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

0 commit comments

Comments
 (0)