Adding sync block macro
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
use oxydsp_flowgraph::edge::{In, Out};
|
||||
use oxydsp_flowgraph_macros::BlockIO;
|
||||
use oxydsp_flowgraph::{
|
||||
block::SyncBlock,
|
||||
edge::{In, Out},
|
||||
};
|
||||
use oxydsp_flowgraph_macros::{BlockIO, sync_block};
|
||||
|
||||
#[derive(BlockIO)]
|
||||
//#[sync_block]
|
||||
pub struct Test
|
||||
{
|
||||
#[input]
|
||||
@ -11,4 +15,35 @@ pub struct Test
|
||||
output: Out<u32>,
|
||||
}
|
||||
|
||||
impl oxydsp_flowgraph::block::Block for Test
|
||||
{
|
||||
fn work(&mut self) -> oxydsp_flowgraph::block::BlockResult
|
||||
{
|
||||
let mut len = usize::MAX;
|
||||
let mut input_reader = self.input.read();
|
||||
len = len.min(input_reader.len());
|
||||
let mut output_writer = self.output.write();
|
||||
len = len.min(output_writer.len());
|
||||
for _ in 0..len
|
||||
{
|
||||
let input = input_reader.pop().unwrap();
|
||||
let (output_out,) = self.sync_work((input,));
|
||||
output_writer.push(output_out).unwrap();
|
||||
}
|
||||
oxydsp_flowgraph::block::BlockResult::Ok
|
||||
}
|
||||
}
|
||||
|
||||
impl SyncBlock for Test
|
||||
{
|
||||
type Input = (u32,);
|
||||
|
||||
type Output = (u32,);
|
||||
|
||||
fn sync_work(&mut self, (num,): Self::Input) -> Self::Output
|
||||
{
|
||||
(num,)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
Reference in New Issue
Block a user