Simple 2FSK
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
use crate::block::GraphableBlock;
|
||||
|
||||
#[macro_export]
|
||||
@ -33,22 +35,35 @@ impl FlowGraph
|
||||
self.blocks.push(Box::new(block));
|
||||
}
|
||||
|
||||
pub fn run(mut self)
|
||||
pub fn run(mut self) -> JoinHandle<()>
|
||||
{
|
||||
self.populate_edges();
|
||||
let mut k = vec![];
|
||||
for mut x in self.blocks.into_iter()
|
||||
{
|
||||
k.push(std::thread::spawn(move || {
|
||||
loop
|
||||
|
||||
std::thread::spawn(move || {
|
||||
'outer: loop
|
||||
{
|
||||
for x in self.blocks.iter_mut()
|
||||
{
|
||||
match x.work()
|
||||
{
|
||||
crate::block::BlockResult::Ok =>
|
||||
{}
|
||||
crate::block::BlockResult::Terminated =>
|
||||
{
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _ in 0..10_000
|
||||
{
|
||||
for x in self.blocks.iter_mut()
|
||||
{
|
||||
x.work();
|
||||
}
|
||||
}));
|
||||
}
|
||||
k.into_iter().for_each(|j| {
|
||||
let _ = j.join();
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn populate_edges(&mut self)
|
||||
|
||||
Reference in New Issue
Block a user