timely_communication/
logging.rs

1//! Configuration and events for communication logging.
2
3use columnar::Columnar;
4use serde::{Serialize, Deserialize};
5use timely_container::CapacityContainerBuilder;
6
7/// Configuration information about a communication thread.
8#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize, Columnar)]
9pub struct CommunicationSetup {
10    /// `true` when this is a send thread (or the receive thread).
11    pub sender: bool,
12    /// The process id of the thread.
13    pub process: usize,
14    /// The remote process id.
15    pub remote: Option<usize>,
16}
17
18/// Various communication events.
19#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize, Columnar)]
20pub enum CommunicationEvent {
21    /// An observed message.
22    Message(MessageEvent),
23    /// A state transition.
24    State(StateEvent),
25    /// Setup event
26    Setup(CommunicationSetup)
27}
28
29/// An observed message.
30#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize, Columnar)]
31pub struct MessageEvent {
32    /// `true` for send event, `false` for receive event
33    pub is_send: bool,
34    /// associated message header.
35    pub header: crate::networking::MessageHeader,
36}
37
38/// Starting or stopping communication threads.
39#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize, Columnar)]
40pub struct StateEvent {
41    /// Is the thread a send (vs a recv) thread.
42    pub send: bool,
43    /// The host process id.
44    pub process: usize,
45    /// The remote process id.
46    pub remote: usize,
47    /// Is the thread starting or stopping.
48    pub start: bool,
49}
50
51impl From<MessageEvent> for CommunicationEvent {
52    fn from(v: MessageEvent) -> CommunicationEvent { CommunicationEvent::Message(v) }
53}
54impl From<StateEvent> for CommunicationEvent {
55    fn from(v: StateEvent) -> CommunicationEvent { CommunicationEvent::State(v) }
56}
57
58/// Builder for communication log events.
59pub type CommunicationEventBuilder = CapacityContainerBuilder<Vec<(std::time::Duration, CommunicationEvent)>>;