From b74ab109b1ff9f9b07b309a1e381e567243d2dbc Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Thu, 28 Sep 2017 14:30:51 -0400 Subject: [PATCH] nanosleep for no-thrash --- Cargo.toml | 1 + src/influx.rs | 2 +- src/latency.rs | 3 ++- src/lib.rs | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ad109a8..058e871 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ pub-sub = "2.0" slog = "2.0.6" sloggers = "0.2" slog-term = "2" +shuteye = "^0" windows = { path = "../windows" } money = { path = "../money" } diff --git a/src/influx.rs b/src/influx.rs index e2e7e19..1fd059c 100644 --- a/src/influx.rs +++ b/src/influx.rs @@ -417,7 +417,7 @@ impl InfluxWriter { if !rcvd_msg { #[cfg(feature = "no-thrash")] - thread::sleep(Duration::from_millis(1) / 10); + shuteye::sleep(Duration::new(0, 5000)); } } diff --git a/src/latency.rs b/src/latency.rs index 04bbc1f..1dfda91 100644 --- a/src/latency.rs +++ b/src/latency.rs @@ -10,6 +10,7 @@ use pub_sub::PubSub; use zmq; use influent::measurement::{Measurement, Value}; use sloggers::types::Severity; +use shuteye; use windows::{DurationWindow, Incremental}; use money::{Ticker, Side, ByExchange, Exchange}; @@ -402,7 +403,7 @@ impl Manager { debug!(logger, "sent broadcast"); } else { #[cfg(feature = "no-thrash")] - thread::sleep(Duration::from_millis(1) / 10); + shuteye::sleep(Duration::new(0, 1000)); } if terminate { break } diff --git a/src/lib.rs b/src/lib.rs index d589957..9e12693 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,6 +15,7 @@ extern crate termion; extern crate pub_sub; extern crate sloggers; extern crate slog_term; +extern crate shuteye; extern crate windows;