-
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
383 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::{io, sync::mpsc::SendError}; | ||
|
||
use crate::threading::messages::{ClockCmd, DisplayCmd, SnifferCmd, TrackerCmd}; | ||
|
||
/// Fatal errors that can be encountered by worker threads. | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum ThreadError { | ||
#[error("terminal events iterator terminated unexpectedly")] | ||
TerminalEventsTerminated, | ||
#[error("terminal stop did not complete successfully")] | ||
TerminalStopFail(io::Error), | ||
|
||
#[error("all receivers of a ClockCmd channel have hung up")] | ||
ClockCmdSend, | ||
#[error("all receivers of a DisplayCmd channel have hung up")] | ||
DisplayCmdSend, | ||
#[error("all receivers of a TrackerCmd channel have hung up")] | ||
TrackerCmdSend, | ||
#[error("all receivers of a SnifferCmd channel have hung up")] | ||
SnifferCmdSend, | ||
|
||
#[error("all senders of a ClockCmd channel have hung up")] | ||
ClockCmdRecv, | ||
#[error("all senders of a DisplayCmd channel have hung up")] | ||
DisplayCmdRecv, | ||
#[error("all senders of a TrackerCmd channel have hung up")] | ||
TrackerCmdRecv, | ||
#[error("all senders of a SnifferCmd channel have hung up")] | ||
SnifferCmdRecv, | ||
} | ||
impl From<SendError<ClockCmd>> for ThreadError { | ||
fn from(_: SendError<ClockCmd>) -> Self { | ||
Self::ClockCmdSend | ||
} | ||
} | ||
impl From<SendError<DisplayCmd>> for ThreadError { | ||
fn from(_: SendError<DisplayCmd>) -> Self { | ||
Self::DisplayCmdSend | ||
} | ||
} | ||
impl From<SendError<TrackerCmd>> for ThreadError { | ||
fn from(_: SendError<TrackerCmd>) -> Self { | ||
Self::TrackerCmdSend | ||
} | ||
} | ||
impl From<SendError<SnifferCmd>> for ThreadError { | ||
fn from(_: SendError<SnifferCmd>) -> Self { | ||
Self::SnifferCmdSend | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/// A command sent to the update clock thread. | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
pub enum ClockCmd { | ||
/// Pause the update clock. | ||
Pause, | ||
/// Unpause the update clock. | ||
Unpause, | ||
/// Stop the thread. | ||
Stop, | ||
} | ||
|
||
/// A command sent to the display handler thread. | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
pub enum DisplayCmd { | ||
/// Rerender the display without updating data. | ||
Refresh, | ||
/// Consume the utilisation data generated since last update. | ||
/// | ||
/// Note that this only changes the handler state, but does not trigger a display refresh. | ||
Update, | ||
/// Cycle the order of the tables. | ||
/// | ||
/// Note that this only changes the handler state, but does not trigger a display refresh. | ||
CycleTables, | ||
/// Cleanup the display, then stop the thread. | ||
Stop, | ||
} | ||
|
||
/// A command sent to the utilisation tracker thread. | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
pub enum TrackerCmd { | ||
/// Pause data collection. | ||
Pause, | ||
/// Unpause data collection. | ||
Unpause, | ||
/// Stop the thread. | ||
Stop, | ||
} | ||
|
||
/// A command sent to sniffer threads. | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
pub enum SnifferCmd { | ||
/// Stop the thread. | ||
Stop, | ||
} |
Oops, something went wrong.