forked from M-Labs/zynq-rs
libcortex_a9: impl Iterator for sync_channel::Receiver
This commit is contained in:
parent
e54edbf32d
commit
6fd6f429fe
@ -135,11 +135,9 @@ pub fn main_core0() {
|
|||||||
let core1 = boot::Core1::start(core1_stack);
|
let core1 = boot::Core1::start(core1_stack);
|
||||||
|
|
||||||
|
|
||||||
let (tx, mut rx) = sync_channel(1000);
|
let (tx, mut rx) = sync_channel(10);
|
||||||
*SHARED.lock() = Some(tx);
|
*SHARED.lock() = Some(tx);
|
||||||
let mut i = 0u32;
|
for (i, r) in rx.enumerate() {
|
||||||
loop {
|
|
||||||
let r = rx.recv();
|
|
||||||
// println!("Recvd {}", r);
|
// println!("Recvd {}", r);
|
||||||
if i != *r {
|
if i != *r {
|
||||||
println!("Expected {}, received {}", i, r);
|
println!("Expected {}, received {}", i, r);
|
||||||
@ -147,8 +145,6 @@ pub fn main_core0() {
|
|||||||
if i % 100000 == 0 {
|
if i % 100000 == 0 {
|
||||||
println!("{} Ok", i);
|
println!("{} Ok", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1;
|
|
||||||
}
|
}
|
||||||
core1.reset();
|
core1.reset();
|
||||||
|
|
||||||
@ -253,7 +249,7 @@ pub fn main_core0() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static SHARED: Mutex<Option<sync_channel::Sender<u32>>> = Mutex::new(None);
|
static SHARED: Mutex<Option<sync_channel::Sender<usize>>> = Mutex::new(None);
|
||||||
static DONE: Mutex<bool> = Mutex::new(false);
|
static DONE: Mutex<bool> = Mutex::new(false);
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -102,3 +102,11 @@ impl<T> Receiver<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Iterator for Receiver<T> {
|
||||||
|
type Item = Box<T>;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
Some(self.recv())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user