Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Rust 2018 Edition (and drop dev-dependency on lazy_static) #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "scoped_threadpool"
version = "0.1.9"
authors = ["Marvin Löbel <[email protected]>"]
license = "MIT"
edition = "2018"

description = "A library for scoped and cached threadpools."
readme = "README.md"
Expand All @@ -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 = []
20 changes: 7 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -72,7 +68,7 @@ impl<F: FnOnce()> FnBox for F {
}
}

type Thunk<'a> = Box<FnBox + Send + 'a>;
type Thunk<'a> = Box<dyn FnBox + Send + 'a>;

impl Drop for Pool {
fn drop(&mut self) {
Expand Down Expand Up @@ -403,14 +399,12 @@ mod benches {

// const MS_SLEEP_PER_OP: u32 = 1;

lazy_static! {
static ref POOL_1: Mutex<Pool> = Mutex::new(Pool::new(1));
static ref POOL_2: Mutex<Pool> = Mutex::new(Pool::new(2));
static ref POOL_3: Mutex<Pool> = Mutex::new(Pool::new(3));
static ref POOL_4: Mutex<Pool> = Mutex::new(Pool::new(4));
static ref POOL_5: Mutex<Pool> = Mutex::new(Pool::new(5));
static ref POOL_8: Mutex<Pool> = Mutex::new(Pool::new(8));
}
static POOL_1: Mutex<Pool> = Mutex::new(Pool::new(1));
static POOL_2: Mutex<Pool> = Mutex::new(Pool::new(2));
static POOL_3: Mutex<Pool> = Mutex::new(Pool::new(3));
static POOL_4: Mutex<Pool> = Mutex::new(Pool::new(4));
static POOL_5: Mutex<Pool> = Mutex::new(Pool::new(5));
static POOL_8: Mutex<Pool> = Mutex::new(Pool::new(8));

fn fib(n: u64) -> u64 {
let mut prev_prev: u64 = 1;
Expand Down
6 changes: 3 additions & 3 deletions tests/threads-living-too-long-demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 || {
Expand All @@ -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 || {
Expand Down