d3_components/lib.rs
1//! Beyond the pure running of machines, a structure should be imposed upon them, allowing for interaction.
2//! Many different organizational structures exist, which could be utilzed. This is one of them, it is a
3//! Component, Connector model with a Coordinator Component providing orchestration. Although this is the
4//! model being discussed there is no requirement that it be the only model used. It is one I happen to
5//! like and provides some nice characteristics.
6//!
7//! The primary benefit of this model is that it reduces most things down to a wiring problem, which
8//! works nicely if you can accomplish everything by wiring senders together. The other benefit is
9//! the incredibly small API which needs to be exposed. Ideally, it consists of a configure per
10//! component.
11//!
12//! There are two examples provided, that illustrate this:
13//! * A chat server, which allows all joiners to chat with each other via TCP.
14//! * An echo server, which echos back anything sent to it.
15//!
16//! Components may interact with the network as well as other components. They are factories for
17//! connections. Connections are the work-horses of machines. They may spawn additional machines
18//! as part of their function. They provide scaling of the server. The Coordinator is a Component
19//! with some added responsiblities. It is responsible for wiring Connectors together in a meaningful
20//! manner.
21//!
22//! Taken together, this model can be used for implementing a simple echo server all the way up to a
23//! more complex conference server, which would include audio, video, recording and translating services.
24#[macro_use] extern crate smart_default;
25#[macro_use] extern crate serde_derive;
26
27use std::sync::Arc;
28use std::thread;
29use std::time::Duration;
30
31use atomic_refcell::AtomicRefCell;
32use crossbeam::atomic::AtomicCell;
33use crossbeam::channel;
34#[allow(unused_imports)] use d3_core::executor::*;
35use d3_core::machine_impl::*;
36use d3_core::send_cmd;
37use d3_derive::*;
38
39mod net_instruction_set;
40use net_instruction_set::{NetCmd, NetConnId, NetSender};
41
42pub mod components;
43pub mod coordinators;
44mod mio_network;
45pub mod settings;
46
47mod network_start_stop;
48use network_start_stop::{NetworkControl, NetworkControlObj, NetworkFactory, NetworkFactoryObj};
49pub mod network {
50 pub use crate::net_instruction_set::{NetCmd, NetConnId, NetSender};
51 pub use crate::network_start_stop::{get_network_sender, start_network, stop_network};
52}