Crate dharma [] [src]

dharma crate provides high-level multi-threading support.

bridge module

bridge module provides similar functionality as standard spmc but instead of producing fixed pairs Sender-Receiver it allows to connect them freely, so we can have many one Sender sending to many Receivers and one Receiver listening to many senders in flexible, configurable way.

signaler module

On to of that we add Signaler which can subscribe receivers for signals (application defined events) creating notification mechanism.

event_loop module

On top of Signaler we add EventLoop, which is event queue assigned to thread. EventLoop has assigned Modules constituting separate application components. Modules can be assigned to EventLoops in flexible way making it easy to control tasks processed in threads. Modules do not share memory and communicate with signals.

dispatcher module

Every threading framework should provide mechanism for listening on system events. Dispatcher allows to register EventHandlers (wrapping file descriptors) and invokes them when system events they are assigned are ready to be processed.

system module

Last module contains helper code for and handling system signals.


pub use bridge::connect;
pub use bridge::direct_connect;
pub use bridge::DirectSender;
pub use bridge::Sender;
pub use bridge::Receiver;
pub use bridge::ReceiveResult;
pub use bridge::SignalId;
pub use bridge::SpecialCommand;
pub use signaler::Signaler;
pub use event_loop::EventLoop;
pub use event_loop::EventLoopInfo;
pub use event_loop::ServiceInfo;
pub use event_loop::Module;
pub use event_loop::ModuleConstructor;
pub use event_loop::Service;
pub use event_loop::ServiceConstructor;
pub use dispatcher::Dispatcher;
pub use dispatcher::DispatcherController;
pub use dispatcher::LocalDispatcher;
pub use dispatcher::LocalDispatcherController;
pub use dispatcher::EventHandler;
pub use dispatcher::EventHandlerId;
pub use dispatcher::EventKind;
pub use dispatcher::event_kind;
pub use system::block_signals;
pub use system::unblock_signals;
pub use system::SignalEventHandler;
pub use timer::Timer;



Communication between two endpoints in different threads.


Handling system events (epoll wrapper).


Implementation of main thread loop with notification listening.


Notification sender.


System signal handling.


Timer functionality