Adding sync block macro

This commit is contained in:
2026-03-12 15:24:03 +01:00
parent 008a765fe3
commit e13b4a49b5
7 changed files with 320 additions and 25 deletions

View File

@ -1,4 +1,4 @@
use crate::edge::BlockIOIndex;
use crate::edge::{AnonymousStreamConsumer, AnonymousStreamProducer, BlockIOIndex};
pub enum BlockResult
{
@ -16,8 +16,18 @@ pub trait BlockIO
fn set_index(&self, block_index: usize);
// Number of input/output ports
fn input_count(&self);
fn output_count(&self);
fn input_count(&self) -> usize;
fn output_count(&self) -> usize;
// Stream managment
fn set_anonymous_out_stream(&mut self, output_index: usize, producer: AnonymousStreamProducer);
fn set_anonymous_in_stream(&mut self, input_index: usize, consumer: AnonymousStreamConsumer);
fn create_anonymous_stream_for(
&mut self,
output_index: usize,
capacity: usize,
) -> (AnonymousStreamProducer, AnonymousStreamConsumer);
}
pub trait Block
@ -25,4 +35,12 @@ pub trait Block
fn work(&mut self) -> BlockResult;
}
pub trait SyncBlock
{
type Input;
type Output;
fn sync_work(&mut self, input: Self::Input) -> Self::Output;
}
pub trait GraphableBlock: Block + BlockIO {}