Forwards rb functions in in and out

This commit is contained in:
2026-03-05 23:12:51 +01:00
parent ed9027d12c
commit 5f86cb2cd6
2 changed files with 21 additions and 4 deletions

View File

@ -1,7 +1,5 @@
use petgraph::graph::DiGraph;
use petgraph::graph::NodeIndex;
use crate::Block;
use petgraph::graph::DiGraph;
pub struct Graph
{

View File

@ -1,6 +1,8 @@
use ringbuf::HeapRb;
use ringbuf::SharedRb;
use ringbuf::consumer::PopIter;
use ringbuf::storage::Heap;
use ringbuf::traits::Consumer;
use ringbuf::traits::Producer;
use ringbuf::traits::Split;
use ringbuf::wrap::caching::Caching;
@ -15,7 +17,7 @@ pub struct In<T>
pub rb: Caching<Arc<SharedRb<Heap<T>>>, false, true>,
}
// Represent a block input, in which data is pushed
// Represent a block output, in which data is pushed
pub struct Out<T>
{
to: Rc<Cell<Option<usize>>>,
@ -49,6 +51,16 @@ impl<T> In<T>
{
self.block.set(Some(index))
}
pub fn try_pop(&mut self) -> Option<T>
{
self.rb.try_pop()
}
pub fn pop_iter(&mut self) -> PopIter<'_, Caching<Arc<SharedRb<Heap<T>>>, false, true>>
{
self.rb.pop_iter()
}
}
impl<T> Out<T>
@ -62,4 +74,11 @@ impl<T> Out<T>
{
self.rb.try_push(data)
}
pub fn push_iter<I>(&mut self, iter: I) -> usize
where
I: Iterator<Item = T>,
{
self.rb.push_iter(iter)
}
}