Progress on syncblock macro
This commit is contained in:
@ -20,31 +20,79 @@ use oxydsp_dsp::units::DigitalFrequency;
|
||||
use oxydsp_flowgraph::BlockIO;
|
||||
use oxydsp_flowgraph::block::Block;
|
||||
use oxydsp_flowgraph::block::BlockResult;
|
||||
use oxydsp_flowgraph::block::SyncBlock;
|
||||
use oxydsp_flowgraph::block::SyncBlockIO;
|
||||
use oxydsp_flowgraph::flowgraph;
|
||||
use oxydsp_flowgraph::graph::FlowGraph;
|
||||
use oxydsp_flowgraph::io::In;
|
||||
use oxydsp_flowgraph::io::Out;
|
||||
use oxydsp_flowgraph::io::PopIterable;
|
||||
use oxydsp_flowgraph::sync_block;
|
||||
|
||||
use crate::printer_synchronous_block::PrinterView;
|
||||
|
||||
#[derive(BlockIO)]
|
||||
#[sync_block]
|
||||
pub struct Printer<T: 'static>
|
||||
{
|
||||
#[input]
|
||||
input: In<T>,
|
||||
|
||||
#[input]
|
||||
input_b: In<u32>,
|
||||
|
||||
#[output]
|
||||
output_a: Out<u32>,
|
||||
|
||||
n: usize,
|
||||
}
|
||||
|
||||
impl<T: 'static> SyncBlockIO for Printer<T>
|
||||
impl<'view, T> SyncBlock<'view> for Printer<T>
|
||||
{
|
||||
type StateView = u32;
|
||||
|
||||
type Input = T;
|
||||
|
||||
type Output = T;
|
||||
fn sync_work(state: Self::StateView, input: Self::Input) -> Option<Self::Output>
|
||||
{
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Block for Printer<T>
|
||||
{
|
||||
fn work(&mut self) -> BlockResult
|
||||
{
|
||||
let state = PrinterView {
|
||||
n: &mut self.n,
|
||||
_sync_block_phantom: Default::default(),
|
||||
};
|
||||
|
||||
let output_a_write = self.output_a.write();
|
||||
(&mut self.input, &mut self.input_b).pop_iter().for_each(
|
||||
|((input_el, input_tag), (input_b_el, input_b_tag))| {
|
||||
let new_tag = Tag::from([input_tag, input_b_tag]);
|
||||
let output_a_el = <Self as SyncBlock>::sync_work(state, (input_el, input_b_el));
|
||||
|
||||
output_a_write.push((output_a_el, new_tag));
|
||||
},
|
||||
);
|
||||
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
// mod printer_synchronous_block
|
||||
// {
|
||||
// struct PrinterView<'view, T>
|
||||
// {
|
||||
// n: &'view mut usize,
|
||||
// _sync_block_phantom: std::marker::PhantomData<'view, T>,
|
||||
// }
|
||||
// impl<'view, T: 'static> oxydsp_flowgraph::block::SyncBlockIO<'view> for super::Printer<T>
|
||||
// {
|
||||
// type StateView = PrinterView<'view, T>;
|
||||
// type Input = ();
|
||||
// type Output = ();
|
||||
// }
|
||||
// }
|
||||
|
||||
impl<T: 'static> Printer<T>
|
||||
{
|
||||
pub fn new(input: In<T>) -> Self
|
||||
|
||||
Reference in New Issue
Block a user