From 024de13a6d144b33cbf4bc75bf394768d08865c0 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Mon, 4 Jan 2021 21:45:38 -0500 Subject: [PATCH] Rust 2018 Edition --- Cargo.toml | 4 +--- src/lib.rs | 20 +++++++------------- tests/threads-living-too-long-demo.rs | 6 +++--- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d18659b..81b72c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "scoped_threadpool" version = "0.1.9" authors = ["Marvin Löbel "] license = "MIT" +edition = "2018" description = "A library for scoped and cached threadpools." readme = "README.md" @@ -11,8 +12,5 @@ documentation = "http://kimundi.github.io/scoped-threadpool-rs/scoped_threadpool repository = "https://github.com/Kimundi/scoped-threadpool-rs" keywords = ["thread", "scoped", "pool", "cached", "threadpool"] -[dev-dependencies] -lazy_static = "1.0" - [features] nightly = [] diff --git a/src/lib.rs b/src/lib.rs index 1fc01ea..fdceecd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,10 +47,6 @@ #![warn(missing_docs)] -#[macro_use] -#[cfg(test)] -extern crate lazy_static; - use std::thread::{self, JoinHandle}; use std::sync::mpsc::{channel, Sender, Receiver, SyncSender, sync_channel, RecvError}; use std::sync::{Arc, Mutex}; @@ -72,7 +68,7 @@ impl FnBox for F { } } -type Thunk<'a> = Box; +type Thunk<'a> = Box; impl Drop for Pool { fn drop(&mut self) { @@ -403,14 +399,12 @@ mod benches { // const MS_SLEEP_PER_OP: u32 = 1; - lazy_static! { - static ref POOL_1: Mutex = Mutex::new(Pool::new(1)); - static ref POOL_2: Mutex = Mutex::new(Pool::new(2)); - static ref POOL_3: Mutex = Mutex::new(Pool::new(3)); - static ref POOL_4: Mutex = Mutex::new(Pool::new(4)); - static ref POOL_5: Mutex = Mutex::new(Pool::new(5)); - static ref POOL_8: Mutex = Mutex::new(Pool::new(8)); - } + static POOL_1: Mutex = Mutex::new(Pool::new(1)); + static POOL_2: Mutex = Mutex::new(Pool::new(2)); + static POOL_3: Mutex = Mutex::new(Pool::new(3)); + static POOL_4: Mutex = Mutex::new(Pool::new(4)); + static POOL_5: Mutex = Mutex::new(Pool::new(5)); + static POOL_8: Mutex = Mutex::new(Pool::new(8)); fn fib(n: u64) -> u64 { let mut prev_prev: u64 = 1; diff --git a/tests/threads-living-too-long-demo.rs b/tests/threads-living-too-long-demo.rs index 9302588..23ee93a 100644 --- a/tests/threads-living-too-long-demo.rs +++ b/tests/threads-living-too-long-demo.rs @@ -2,7 +2,7 @@ extern crate scoped_threadpool; use scoped_threadpool::Pool; use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT}; +use std::sync::atomic::AtomicBool; use std::panic::AssertUnwindSafe; // The representation invariant for PositivelyAtomic is that it is @@ -35,7 +35,7 @@ impl PositivelyAtomic { #[test] fn demo_stack_allocated() { - static SAW_ZERO: AtomicBool = ATOMIC_BOOL_INIT; + static SAW_ZERO: AtomicBool = AtomicBool::new(false); for _i in 0..100 { let saw_zero = &AssertUnwindSafe(&SAW_ZERO); let _p = ::std::panic::catch_unwind(move || { @@ -51,7 +51,7 @@ fn demo_stack_allocated() { #[test] fn demo_heap_allocated() { - static SAW_ZERO: AtomicBool = ATOMIC_BOOL_INIT; + static SAW_ZERO: AtomicBool = AtomicBool::new(false); for i in 0..100 { let saw_zero = &AssertUnwindSafe(&SAW_ZERO); let _p = ::std::panic::catch_unwind(move || {