use std::sync::{Arc, Mutex};
use crate::operator::Operator;
pub(super) mod collect;
pub(super) mod collect_channel;
pub(super) mod collect_count;
pub(super) mod collect_vec;
pub(super) mod for_each;
pub(crate) trait Sink: Operator<Out = ()> {}
pub(crate) type StreamOutputRef<Out> = Arc<Mutex<Option<Out>>>;
pub struct StreamOutput<Out> {
result: StreamOutputRef<Out>,
}
impl<Out> From<StreamOutputRef<Out>> for StreamOutput<Out> {
fn from(value: StreamOutputRef<Out>) -> Self {
Self { result: value }
}
}
impl<Out> StreamOutput<Out> {
pub fn get(self) -> Option<Out> {
self.result
.try_lock()
.expect("Cannot lock output result")
.take()
}
}