-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from FrancisRussell/develop
Release 0.6.0
- Loading branch information
Showing
10 changed files
with
119 additions
and
52 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "zoog" | ||
version = "0.5.1" | ||
version = "0.6.0" | ||
authors = ["Francis Russell <[email protected]>"] | ||
edition = "2018" | ||
homepage = "https://github.com/FrancisRussell/zoog" | ||
|
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
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,31 @@ | ||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
use std::sync::Arc; | ||
|
||
use zoog::interrupt::Interrupt; | ||
|
||
pub type CtrlCRegistrationError = ctrlc::Error; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct CtrlCChecker { | ||
running: Arc<AtomicBool>, | ||
} | ||
|
||
impl CtrlCChecker { | ||
pub fn new() -> Result<CtrlCChecker, CtrlCRegistrationError> { | ||
let running = Arc::new(AtomicBool::new(true)); | ||
{ | ||
let running = running.clone(); | ||
ctrlc::set_handler(move || { | ||
running.store(false, Ordering::Relaxed); | ||
})?; | ||
} | ||
let result = CtrlCChecker { running }; | ||
Ok(result) | ||
} | ||
|
||
pub fn is_running(&self) -> bool { self.running.load(Ordering::Relaxed) } | ||
} | ||
|
||
impl Interrupt for CtrlCChecker { | ||
fn is_set(&self) -> bool { !self.is_running() } | ||
} |
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
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 |
---|---|---|
@@ -1,25 +1,13 @@ | ||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
use std::sync::Arc; | ||
|
||
pub type InteruptRegistrationError = ctrlc::Error; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct InterruptChecker { | ||
running: Arc<AtomicBool>, | ||
/// Allows reading the status of a potential interrupt | ||
pub trait Interrupt { | ||
/// Has the interrupt been triggered? | ||
fn is_set(&self) -> bool; | ||
} | ||
|
||
impl InterruptChecker { | ||
pub fn new() -> Result<InterruptChecker, InteruptRegistrationError> { | ||
let running = Arc::new(AtomicBool::new(true)); | ||
{ | ||
let running = running.clone(); | ||
ctrlc::set_handler(move || { | ||
running.store(false, Ordering::Relaxed); | ||
})?; | ||
} | ||
let result = InterruptChecker { running }; | ||
Ok(result) | ||
} | ||
/// An interrupt that is never triggered | ||
#[derive(Debug, Default)] | ||
pub struct Never {} | ||
|
||
pub fn is_running(&self) -> bool { self.running.load(Ordering::Relaxed) } | ||
impl Interrupt for Never { | ||
fn is_set(&self) -> bool { false } | ||
} |
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