Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 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: 3 additions & 1 deletion spellcheck.dic
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
300
302
&
+
<
Expand Down Expand Up @@ -139,6 +139,7 @@ implementers
implementor
implementors
incrementing
initializer
inlining
interoperate
invariants
Expand Down Expand Up @@ -299,3 +300,4 @@ Wakers
wakeup
wakeups
workstealing
ZSTs
86 changes: 43 additions & 43 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ default = []

# enable everything
full = [
"fs",
"io-util",
"io-std",
"macros",
"net",
"parking_lot",
"process",
"rt",
"rt-multi-thread",
"signal",
"sync",
"time",
"fs",
"io-util",
"io-std",
"macros",
"net",
"parking_lot",
"process",
"rt",
"rt-multi-thread",
"signal",
"sync",
"time",
]

fs = []
Expand All @@ -47,39 +47,39 @@ io-util = ["bytes"]
io-std = []
macros = ["tokio-macros"]
net = [
"libc",
"mio/os-poll",
"mio/os-ext",
"mio/net",
"socket2",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_Security",
"windows-sys/Win32_Storage_FileSystem",
"windows-sys/Win32_System_Pipes",
"windows-sys/Win32_System_SystemServices",
"libc",
"mio/os-poll",
"mio/os-ext",
"mio/net",
"socket2",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_Security",
"windows-sys/Win32_Storage_FileSystem",
"windows-sys/Win32_System_Pipes",
"windows-sys/Win32_System_SystemServices",
]
process = [
"bytes",
"libc",
"mio/os-poll",
"mio/os-ext",
"mio/net",
"signal-hook-registry",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_System_Threading",
"windows-sys/Win32_System_WindowsProgramming",
"bytes",
"libc",
"mio/os-poll",
"mio/os-ext",
"mio/net",
"signal-hook-registry",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_System_Threading",
"windows-sys/Win32_System_WindowsProgramming",
]
# Includes basic task execution capabilities
rt = []
rt-multi-thread = ["rt"]
signal = [
"libc",
"mio/os-poll",
"mio/net",
"mio/os-ext",
"signal-hook-registry",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_System_Console",
"libc",
"mio/os-poll",
"mio/net",
"mio/os-ext",
"signal-hook-registry",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_System_Console",
]
sync = []
test-util = ["rt", "sync", "time"]
Expand Down Expand Up @@ -123,8 +123,8 @@ optional = true
[target.'cfg(windows)'.dev-dependencies.windows-sys]
version = "0.52"
features = [
"Win32_Foundation",
"Win32_Security_Authorization",
"Win32_Foundation",
"Win32_Security_Authorization",
]

[dev-dependencies]
Expand Down Expand Up @@ -169,9 +169,9 @@ features = ["full", "test-util"]
# The following are types that are allowed to be exposed in Tokio's public API.
# The standard library is allowed by default.
allowed_external_types = [
"bytes::buf::buf_impl::Buf",
"bytes::buf::buf_mut::BufMut",
"tokio_macros::*",
"bytes::buf::buf_impl::Buf",
"bytes::buf::buf_mut::BufMut",
"tokio_macros::*",
]

[lints]
Expand Down
35 changes: 35 additions & 0 deletions tokio/src/loom/std/atomic_u8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::cell::UnsafeCell;
use std::fmt;
use std::ops::Deref;
use std::panic;

/// `AtomicU8` providing an additional `with_mut` function.
pub(crate) struct AtomicU8 {
inner: std::sync::atomic::AtomicU8,
}

impl AtomicU8 {
pub(crate) const fn new(val: u8) -> AtomicU8 {
let inner = std::sync::atomic::AtomicU8::new(val);
AtomicU8 { inner }
}

/// Get access to a mutable reference to the inner value.
pub(crate) fn with_mut<R>(&mut self, f: impl FnOnce(&mut u8) -> R) -> R {
f(self.inner.get_mut())
}
}

impl Deref for AtomicU8 {
type Target = std::sync::atomic::AtomicU8;

fn deref(&self) -> &Self::Target {
&self.inner
}
}

impl fmt::Debug for AtomicU8 {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
self.deref().fmt(fmt)
}
}
4 changes: 3 additions & 1 deletion tokio/src/loom/std/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
mod atomic_u16;
mod atomic_u32;
mod atomic_u64;
mod atomic_u8;
mod atomic_usize;
mod barrier;
mod mutex;
Expand Down Expand Up @@ -77,9 +78,10 @@ pub(crate) mod sync {
pub(crate) use crate::loom::std::atomic_u16::AtomicU16;
pub(crate) use crate::loom::std::atomic_u32::AtomicU32;
pub(crate) use crate::loom::std::atomic_u64::{AtomicU64, StaticAtomicU64};
pub(crate) use crate::loom::std::atomic_u8::AtomicU8;
pub(crate) use crate::loom::std::atomic_usize::AtomicUsize;

pub(crate) use std::sync::atomic::{fence, AtomicBool, AtomicPtr, AtomicU8, Ordering};
pub(crate) use std::sync::atomic::{fence, AtomicBool, AtomicPtr, Ordering};
}

pub(crate) use super::barrier::Barrier;
Expand Down
14 changes: 14 additions & 0 deletions tokio/src/macros/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ macro_rules! cfg_io_driver_impl {
}
}

macro_rules! cfg_io_driver_or_sync {
( $( $item:item )* ) => {
$(
#[cfg(any(
feature = "net",
all(unix, feature = "process"),
all(unix, feature = "signal"),
feature = "sync",
))]
$item
)*
}
}

macro_rules! cfg_not_io_driver {
($($item:item)*) => {
$(
Expand Down
27 changes: 0 additions & 27 deletions tokio/src/sync/batch_semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,33 +193,6 @@ impl Semaphore {
}
}

/// Creates a new closed semaphore with 0 permits.
pub(crate) fn new_closed() -> Self {
Self {
permits: AtomicUsize::new(Self::CLOSED),
waiters: Mutex::new(Waitlist {
queue: LinkedList::new(),
closed: true,
}),
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span::none(),
}
}

/// Creates a new closed semaphore with 0 permits.
#[cfg(not(all(loom, test)))]
pub(crate) const fn const_new_closed() -> Self {
Self {
permits: AtomicUsize::new(Self::CLOSED),
waiters: Mutex::const_new(Waitlist {
queue: LinkedList::new(),
closed: true,
}),
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span::none(),
}
}

/// Returns the current number of available permits.
pub(crate) fn available_permits(&self) -> usize {
self.permits.load(Acquire) >> Self::PERMIT_SHIFT
Expand Down
Loading