1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
use futures::channel::mpsc;
use futures::channel::oneshot;

mod block;
mod block_meta;
pub mod buffer;
pub mod config;

#[cfg(not(target_arch = "wasm32"))]
pub mod ctrl_port;

#[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))]
mod logging;
#[cfg(target_os = "android")]
#[path = "logging_android.rs"]
mod logging;
#[cfg(target_arch = "wasm32")]
#[path = "logging_wasm.rs"]
mod logging;

mod flowgraph;
mod message_io;
mod mocker;
#[allow(clippy::module_inception)]
mod runtime;
pub mod scheduler;
mod stream_io;
pub mod tag;
mod topology;

pub use block::Block;
pub use block::Kernel;
pub use block::WorkIo;
pub use block_meta::BlockMeta;
pub use block_meta::BlockMetaBuilder;
pub use flowgraph::Flowgraph;
pub use flowgraph::FlowgraphHandle;
pub use futuresdr_pmt::Pmt;
pub use message_io::MessageInput;
pub use message_io::MessageIo;
pub use message_io::MessageIoBuilder;
pub use message_io::MessageOutput;
pub use mocker::Mocker;
pub(crate) use runtime::run_block;
pub use runtime::Runtime;
pub use runtime::RuntimeBuilder;
pub use stream_io::StreamInput;
pub use stream_io::StreamIo;
pub use stream_io::StreamIoBuilder;
pub use stream_io::StreamOutput;
pub use tag::ItemTag;
pub use tag::Tag;
pub use topology::Topology;

use crate::runtime::buffer::BufferReader;
use crate::runtime::buffer::BufferWriter;

pub fn init() {
    logging::init();
}

#[derive(Debug)]
pub enum AsyncMessage {
    Initialize,
    Initialized,
    Notify,
    Terminate,
    BlockDone {
        id: usize,
        block: Block,
    },
    StreamOutputInit {
        src_port: usize,
        writer: BufferWriter,
    },
    StreamInputInit {
        dst_port: usize,
        reader: BufferReader,
    },
    StreamInputDone {
        input_id: usize,
    },
    StreamOutputDone {
        output_id: usize,
    },
    MessageOutputConnect {
        src_port: usize,
        dst_port: usize,
        dst_inbox: mpsc::Sender<AsyncMessage>,
    },
    Call {
        port_id: usize,
        data: Pmt,
    },
    Callback {
        port_id: usize,
        data: Pmt,
        tx: oneshot::Sender<Pmt>,
    },
    BlockCall {
        block_id: usize,
        port_id: usize,
        data: Pmt,
    },
    BlockCallback {
        block_id: usize,
        port_id: usize,
        data: Pmt,
        tx: oneshot::Sender<Pmt>,
    },
}