Skip to content

Commit

Permalink
Use maybe-uninit crate to bridge backwards compatibility issues with …
Browse files Browse the repository at this point in the history
…MaybeUninit
  • Loading branch information
cynecx committed Feb 10, 2020
1 parent 7de64fe commit b5525b7
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 7 deletions.
3 changes: 3 additions & 0 deletions crossbeam-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ description = "Multi-producer multi-consumer channels for message passing"
keywords = ["channel", "mpmc", "select", "golang", "message"]
categories = ["algorithms", "concurrency", "data-structures"]

[dependencies]
maybe-uninit = "2.0.0"

[dependencies.crossbeam-utils]
version = "0.7"
path = "../crossbeam-utils"
Expand Down
4 changes: 3 additions & 1 deletion crossbeam-channel/src/flavors/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@

use std::cell::UnsafeCell;
use std::marker::PhantomData;
use std::mem::{self, MaybeUninit};
use std::mem;
use std::ptr;
use std::sync::atomic::{self, AtomicUsize, Ordering};
use std::time::Instant;

use crossbeam_utils::{Backoff, CachePadded};

use maybe_uninit::MaybeUninit;

use context::Context;
use err::{RecvTimeoutError, SendTimeoutError, TryRecvError, TrySendError};
use select::{Operation, SelectHandle, Selected, Token};
Expand Down
3 changes: 2 additions & 1 deletion crossbeam-channel/src/flavors/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

use std::cell::UnsafeCell;
use std::marker::PhantomData;
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::atomic::{self, AtomicPtr, AtomicUsize, Ordering};
use std::time::Instant;

use crossbeam_utils::{Backoff, CachePadded};

use maybe_uninit::MaybeUninit;

use context::Context;
use err::{RecvTimeoutError, SendTimeoutError, TryRecvError, TrySendError};
use select::{Operation, SelectHandle, Selected, Token};
Expand Down
1 change: 1 addition & 0 deletions crossbeam-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
#![warn(missing_debug_implementations)]

extern crate crossbeam_utils;
extern crate maybe_uninit;

mod channel;
mod context;
Expand Down
3 changes: 3 additions & 0 deletions crossbeam-deque/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ description = "Concurrent work-stealing deque"
keywords = ["chase-lev", "lock-free", "scheduler", "scheduling"]
categories = ["algorithms", "concurrency", "data-structures"]

[dependencies]
maybe-uninit = "2.0.0"

[dependencies.crossbeam-epoch]
version = "0.8"
path = "../crossbeam-epoch"
Expand Down
6 changes: 5 additions & 1 deletion crossbeam-deque/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,23 @@
extern crate crossbeam_epoch as epoch;
extern crate crossbeam_utils as utils;

extern crate maybe_uninit;

use std::cell::{Cell, UnsafeCell};
use std::cmp;
use std::fmt;
use std::iter::FromIterator;
use std::marker::PhantomData;
use std::mem::{self, MaybeUninit};
use std::mem;
use std::ptr;
use std::sync::atomic::{self, AtomicIsize, AtomicPtr, AtomicUsize, Ordering};
use std::sync::Arc;

use epoch::{Atomic, Owned};
use utils::{Backoff, CachePadded};

use maybe_uninit::MaybeUninit;

// Minimum buffer capacity.
const MIN_CAP: usize = 64;
// Maximum number of tasks that can be stolen in `steal_batch()` and `steal_batch_and_pop()`.
Expand Down
1 change: 1 addition & 0 deletions crossbeam-epoch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sanitize = [] # Makes it more likely to trigger any potential data races.

[dependencies]
cfg-if = "0.1.2"
maybe-uninit = "2.0.0"
memoffset = "0.5"

[dependencies.crossbeam-utils]
Expand Down
4 changes: 3 additions & 1 deletion crossbeam-epoch/src/deferred.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use alloc::boxed::Box;
use core::fmt;
use core::marker::PhantomData;
use core::mem::{self, MaybeUninit};
use core::mem;
use core::ptr;

use maybe_uninit::MaybeUninit;

/// Number of words a piece of `Data` can hold.
///
/// Three words should be enough for the majority of cases. For example, you can fit inside it the
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-epoch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ extern crate cfg_if;
#[cfg(feature = "std")]
extern crate core;

extern crate maybe_uninit;

cfg_if! {
if #[cfg(feature = "alloc")] {
extern crate alloc;
Expand Down
3 changes: 2 additions & 1 deletion crossbeam-epoch/src/sync/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
//! Simon Doherty, Lindsay Groves, Victor Luchangco, and Mark Moir. 2004b. Formal Verification of a
//! Practical Lock-Free Queue Algorithm. https://doi.org/10.1007/978-3-540-30232-2_7

use core::mem::MaybeUninit;
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release};

use crossbeam_utils::CachePadded;

use maybe_uninit::MaybeUninit;

use {unprotected, Atomic, Guard, Owned, Shared};

// The representation here is a singly-linked list, with a sentinel node at the front. In general
Expand Down
1 change: 1 addition & 0 deletions crossbeam-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ alloc = ["crossbeam-utils/alloc"]

[dependencies]
cfg-if = "0.1.2"
maybe-uninit = "2.0.0"

[dependencies.crossbeam-utils]
version = "0.7"
Expand Down
4 changes: 3 additions & 1 deletion crossbeam-queue/src/array_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ use alloc::vec::Vec;
use core::cell::UnsafeCell;
use core::fmt;
use core::marker::PhantomData;
use core::mem::{self, MaybeUninit};
use core::mem;
use core::ptr;
use core::sync::atomic::{self, AtomicUsize, Ordering};

use crossbeam_utils::{Backoff, CachePadded};

use maybe_uninit::MaybeUninit;

use err::{PopError, PushError};

/// A slot in a queue.
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ extern crate cfg_if;
#[cfg(feature = "std")]
extern crate core;

extern crate maybe_uninit;

cfg_if! {
if #[cfg(feature = "alloc")] {
extern crate alloc;
Expand Down
3 changes: 2 additions & 1 deletion crossbeam-queue/src/seg_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use alloc::boxed::Box;
use core::cell::UnsafeCell;
use core::fmt;
use core::marker::PhantomData;
use core::mem::MaybeUninit;
use core::ptr;
use core::sync::atomic::{self, AtomicPtr, AtomicUsize, Ordering};

use crossbeam_utils::{Backoff, CachePadded};

use maybe_uninit::MaybeUninit;

use err::PopError;

// Bits indicating the state of a slot:
Expand Down

0 comments on commit b5525b7

Please sign in to comment.