libasync: pass time
This commit is contained in:
parent
8a98cef3fc
commit
ab2a8db4d3
|
@ -241,8 +241,11 @@ pub fn main_core0() {
|
||||||
.map_err(|e| println!("Connection: {:?}", e));
|
.map_err(|e| println!("Connection: {:?}", e));
|
||||||
});
|
});
|
||||||
|
|
||||||
Sockets::run(&mut iface);
|
let mut time = 0u32;
|
||||||
// let mut time = 0u32;
|
Sockets::run(&mut iface, || {
|
||||||
|
time += 1;
|
||||||
|
Instant::from_millis(time)
|
||||||
|
});
|
||||||
// loop {
|
// loop {
|
||||||
// time += 1;
|
// time += 1;
|
||||||
// let timestamp = Instant::from_millis(time);
|
// let timestamp = Instant::from_millis(time);
|
||||||
|
|
|
@ -35,15 +35,20 @@ impl Sockets {
|
||||||
sockets,
|
sockets,
|
||||||
wakers,
|
wakers,
|
||||||
};
|
};
|
||||||
|
// println!("sockets initialized");
|
||||||
unsafe { SOCKETS = Some(instance); }
|
unsafe { SOCKETS = Some(instance); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Block and run executor indefinitely while polling the smoltcp
|
/// Block and run executor indefinitely while polling the smoltcp
|
||||||
/// iface
|
/// iface
|
||||||
pub fn run<'b, 'c, 'e, D: for<'d> Device<'d>>(iface: &mut EthernetInterface<'b, 'c, 'e, D>) {
|
pub fn run<'b, 'c, 'e, D: for<'d> Device<'d>>(
|
||||||
|
iface: &mut EthernetInterface<'b, 'c, 'e, D>,
|
||||||
|
mut get_time: impl FnMut() -> Instant,
|
||||||
|
) {
|
||||||
task::block_on(async {
|
task::block_on(async {
|
||||||
loop {
|
loop {
|
||||||
Self::instance().poll(iface);
|
let instant = get_time();
|
||||||
|
Self::instance().poll(iface, instant);
|
||||||
task::r#yield().await;
|
task::r#yield().await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -53,9 +58,11 @@ impl Sockets {
|
||||||
unsafe { SOCKETS.as_ref().expect("Sockets") }
|
unsafe { SOCKETS.as_ref().expect("Sockets") }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll<'b, 'c, 'e, D: for<'d> Device<'d>>(&self, iface: &mut EthernetInterface<'b, 'c, 'e, D>) {
|
fn poll<'b, 'c, 'e, D: for<'d> Device<'d>>(
|
||||||
// TODO:
|
&self,
|
||||||
let instant = Instant::from_millis(0);
|
iface: &mut EthernetInterface<'b, 'c, 'e, D>,
|
||||||
|
instant: Instant
|
||||||
|
) {
|
||||||
let processed = {
|
let processed = {
|
||||||
let mut sockets = self.sockets.borrow_mut();
|
let mut sockets = self.sockets.borrow_mut();
|
||||||
match iface.poll(&mut sockets, instant) {
|
match iface.poll(&mut sockets, instant) {
|
||||||
|
|
Loading…
Reference in New Issue