Roman Zeyde
6 years ago
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with
24 additions and
0 deletions
-
Cargo.toml
-
src/daemon.rs
|
|
@ -14,6 +14,9 @@ edition = "2018" |
|
|
|
[profile.release] |
|
|
|
lto = true |
|
|
|
|
|
|
|
[features] |
|
|
|
latest_rust = [] # use latest Rust features (otherwise, support Rust 1.32) |
|
|
|
|
|
|
|
[dependencies] |
|
|
|
arrayref = "0.3" |
|
|
|
base64 = "0.10" |
|
|
|
|
|
@ -13,6 +13,8 @@ use std::collections::{HashMap, HashSet}; |
|
|
|
use std::io::{BufRead, BufReader, Lines, Write}; |
|
|
|
use std::net::{SocketAddr, TcpStream}; |
|
|
|
use std::path::PathBuf; |
|
|
|
#[cfg(feature = "latest_rust")] |
|
|
|
use std::sync::atomic::{AtomicU64, Ordering}; |
|
|
|
use std::sync::{Arc, Mutex}; |
|
|
|
use std::time::Duration; |
|
|
|
|
|
|
@ -266,10 +268,29 @@ impl Connection { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(feature = "latest_rust")] |
|
|
|
struct Counter { |
|
|
|
value: AtomicU64, |
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(feature = "latest_rust")] |
|
|
|
impl Counter { |
|
|
|
fn new() -> Self { |
|
|
|
Counter { value: 0.into() } |
|
|
|
} |
|
|
|
|
|
|
|
fn next(&self) -> u64 { |
|
|
|
// fetch_add() returns previous value, we want current one
|
|
|
|
self.value.fetch_add(1, Ordering::Relaxed) + 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(not(feature = "latest_rust"))] |
|
|
|
struct Counter { |
|
|
|
value: Mutex<u64>, |
|
|
|
} |
|
|
|
|
|
|
|
#[cfg(not(feature = "latest_rust"))] |
|
|
|
impl Counter { |
|
|
|
fn new() -> Self { |
|
|
|
Counter { |
|
|
|