embassy_supervisor/
dataflow.rs1use crate::{Coupling, TaskNode};
2
3#[cfg(feature = "macros")]
4pub use embassy_supervisor_macros::dataflow;
5
6#[cfg(feature = "macros")]
7pub use embassy_supervisor_macros::dataflow_bundle;
8
9pub use embassy_supervisor_observe::{Sink, Source};
10
11#[derive(Clone, Copy)]
12pub struct Sig<T: ?Sized + 'static> {
14 pub entry: &'static Coupling,
16 pub target: &'static T,
18}
19
20impl TaskNode {
21 pub fn put<T: Sink + Sync>(&self, s: Sig<T>, v: T::Item) {
23 s.target.put(v);
24 }
25
26 #[cfg(feature = "liveness")]
27 pub fn beat_put<T: Sink + Sync>(&self, s: Sig<T>, v: T::Item) {
29 self.beat();
30 s.target.put(v);
31 }
32
33 pub fn get<T: Source + Sync>(&self, s: Sig<T>) -> T::Item {
35 s.target.get()
36 }
37
38 pub fn writer<T: Sync + ?Sized>(&self, s: Sig<T>) -> &'static T {
40 s.target
41 }
42
43 #[cfg(feature = "liveness")]
45 pub fn beat_writer<T: Sync + ?Sized>(&self, s: Sig<T>) -> &'static T {
46 self.beat();
47 s.target
48 }
49
50 pub fn reader<T: Sync + ?Sized>(&self, s: Sig<T>) -> &'static T {
55 s.target
56 }
57}