d3_core/collective/
machine.rs1#[allow(unused_imports)] use super::*;
2
3#[doc(hidden)]
20pub trait MachineBuilder {
21 type InstructionSet: MachineImpl;
23
24 fn build_raw<T>(raw: T, channel_capacity: usize) -> (Arc<Mutex<T>>, Sender<Self::InstructionSet>, MachineAdapter)
26 where
27 T: 'static + Machine<Self::InstructionSet>,
28 <Self as MachineBuilder>::InstructionSet: Send;
29
30 fn build_addition<T>(machine: &Arc<Mutex<T>>, channel_capacity: usize) -> (Sender<Self::InstructionSet>, MachineAdapter)
32 where
33 T: 'static + Machine<Self::InstructionSet>;
34
35 fn build_unbounded<T>(raw: T) -> (Arc<Mutex<T>>, Sender<Self::InstructionSet>, MachineAdapter)
37 where
38 T: 'static + Machine<Self::InstructionSet>,
39 <Self as MachineBuilder>::InstructionSet: Send;
40
41 fn build_addition_unbounded<T>(machine: &Arc<Mutex<T>>) -> (Sender<Self::InstructionSet>, MachineAdapter)
43 where
44 T: 'static + Machine<Self::InstructionSet>,
45 <Self as MachineBuilder>::InstructionSet: Send;
46 fn build_common<T>(
48 raw: T, s: Sender<Self::InstructionSet>, r: Receiver<Self::InstructionSet>,
49 ) -> (Arc<Mutex<T>>, Sender<Self::InstructionSet>, MachineAdapter)
50 where
51 T: 'static + Machine<Self::InstructionSet>,
52 <Self as MachineBuilder>::InstructionSet: Send;
53
54 fn build_addition_common<T>(
55 machine: &Arc<Mutex<T>>, sender: Sender<Self::InstructionSet>, receiver: Receiver<Self::InstructionSet>,
56 ) -> (Sender<Self::InstructionSet>, MachineAdapter)
57 where
58 T: 'static + Machine<Self::InstructionSet>;
59}
60
61#[inline]
78pub fn send_cmd<T>(sender: &Sender<T>, cmd: T)
79where
80 T: MachineImpl + MachineImpl<InstructionSet = T> + std::fmt::Debug,
81{
82 match sender.send(cmd) {
83 Ok(_) => (),
84 Err(e) => log::info!("failed to send instruction: {}", e),
85 }
86}