summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2021-11-10 00:31:10 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2021-11-10 01:20:11 +0100
commitacc112993a48b3581430f407858badb584e628aa (patch)
tree949c79674375aa297feec0ec90792c29255d4685
parent6243b83d111c7cd8690d643ee93e48091a3fe9e1 (diff)
downloadvtcol-acc112993a48b3581430f407858badb584e628aa.tar.gz
switch from lazy_static to atomics
Yeah const fn!
-rw-r--r--Cargo.toml1
-rw-r--r--src/vtcol.rs11
2 files changed, 4 insertions, 8 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1f187f3..a076bb5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,4 +22,3 @@ doc = false
[dependencies]
clap = "2.33"
libc = "0.2"
-lazy_static = "1.4"
diff --git a/src/vtcol.rs b/src/vtcol.rs
index 4b38a8c..6812b51 100644
--- a/src/vtcol.rs
+++ b/src/vtcol.rs
@@ -1,17 +1,14 @@
-use lazy_static::lazy_static;
use std::{fmt,
path::{Path, PathBuf},
- sync::Mutex};
+ sync::atomic::{AtomicBool, Ordering}};
type Fd = libc::c_int;
-lazy_static! {
- static ref VERBOSITY: Mutex<bool> = Mutex::new(false);
-}
+static VERBOSITY: AtomicBool = AtomicBool::new(false);
macro_rules! vrb {
( $( $e:expr ),* ) => {(
- if *VERBOSITY.lock().unwrap() { println!( $( $e ),* ) }
+ if VERBOSITY.load(Ordering::SeqCst) { println!( $( $e ),* ) }
)}
}
@@ -185,7 +182,7 @@ impl<'a> Job
.get_matches();
if matches.is_present("v") {
- *VERBOSITY.lock().unwrap() = true;
+ VERBOSITY.store(true, Ordering::SeqCst);
}
if matches.is_present("l") {