id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
tokio-rs/tokio:tokio/src/util/rand.rs:2
let one = (seed >> 32) as u32; let two = seed as u32; Self::from_pair(one, two) } fn from_pair(s: u32, r: u32) -> Self { if s == 0 && r == 0 { Self { s: 0, r: 1 } } else { Self { s, r } } } } impl FastRand { /// Initialize a new fast ran...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/rand.rs
41
100
tokio-rs/tokio:tokio/src/util/rand.rs:3
fn fastrand(&mut self) -> u32 { let mut s1 = self.one; let s0 = self.two; s1 ^= s1 << 17; s1 = s1 ^ s0 ^ s1 >> 7 ^ s0 >> 16; self.one = s0; self.two = s1; s0.wrapping_add(s1) } } #[cfg(test)] mod tests { use super::*; #[test] fn non_zero_seed_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/rand.rs
81
113
tokio-rs/tokio:tokio/src/util/rand.rs:1
cfg_rt! { mod rt; pub(crate) use rt::RngSeedGenerator; cfg_unstable! { mod rt_unstable; } } /// A seed for random number generation. /// /// In order to make certain functions within a runtime deterministic, a seed /// can be specified at the time of creation. #[allow(unreachable_pub)] #[deriv...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
56aaa43e91c4fbed88f0c2a5b65019ed9a0c3c61
github
async-runtime
https://github.com/tokio-rs/tokio/blob/56aaa43e91c4fbed88f0c2a5b65019ed9a0c3c61/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:2
let one = (seed >> 32) as u32; let mut two = seed as u32; if two == 0 { // This value cannot be zero two = 1; } Self::from_pair(one, two) } fn from_pair(s: u32, r: u32) -> Self { Self { s, r } } } impl FastRand { /// Initialize a new fa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
56aaa43e91c4fbed88f0c2a5b65019ed9a0c3c61
github
async-runtime
https://github.com/tokio-rs/tokio/blob/56aaa43e91c4fbed88f0c2a5b65019ed9a0c3c61/tokio/src/util/rand.rs
41
95
tokio-rs/tokio:tokio/src/util/rand.rs:3
} fn fastrand(&mut self) -> u32 { let mut s1 = self.one; let s0 = self.two; s1 ^= s1 << 17; s1 = s1 ^ s0 ^ s1 >> 7 ^ s0 >> 16; self.one = s0; self.two = s1; s0.wrapping_add(s1) } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
56aaa43e91c4fbed88f0c2a5b65019ed9a0c3c61
github
async-runtime
https://github.com/tokio-rs/tokio/blob/56aaa43e91c4fbed88f0c2a5b65019ed9a0c3c61/tokio/src/util/rand.rs
81
95
tokio-rs/tokio:tokio/src/util/rand.rs:2
let one = (seed >> 32) as u32; let mut two = seed as u32; if two == 0 { // This value cannot be zero two = 1; } Self::from_pair(one, two) } fn from_pair(s: u32, r: u32) -> Self { Self { s, r } } } impl FastRand { /// Initialize a new fa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
1604bc335157be9a131e24cfde55cab3c90ebc92
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1604bc335157be9a131e24cfde55cab3c90ebc92/tokio/src/util/rand.rs
41
91
tokio-rs/tokio:tokio/src/util/rand.rs:3
let s0 = self.two; s1 ^= s1 << 17; s1 = s1 ^ s0 ^ s1 >> 7 ^ s0 >> 16; self.one = s0; self.two = s1; s0.wrapping_add(s1) } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
1604bc335157be9a131e24cfde55cab3c90ebc92
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1604bc335157be9a131e24cfde55cab3c90ebc92/tokio/src/util/rand.rs
81
91
tokio-rs/tokio:tokio/src/util/rand.rs:2
let one = (seed >> 32) as u32; let mut two = seed as u32; if two == 0 { // This value cannot be zero two = 1; } Self::from_pair(one, two) } fn from_pair(s: u32, r: u32) -> Self { Self { s, r } } } impl FastRand { /// Initialize a new fa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210/tokio/src/util/rand.rs
41
96
tokio-rs/tokio:tokio/src/util/rand.rs:3
(mul >> 32) as u32 } fn fastrand(&mut self) -> u32 { let mut s1 = self.one; let s0 = self.two; s1 ^= s1 << 17; s1 = s1 ^ s0 ^ s1 >> 7 ^ s0 >> 16; self.one = s0; self.two = s1; s0.wrapping_add(s1) } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1914e1e4b9bfe6ea2d61970ec3fcf2b5d7bb0210/tokio/src/util/rand.rs
81
96
tokio-rs/tokio:tokio/src/util/rand.rs:1
cfg_rt! { mod rt; pub(crate) use rt::RngSeedGenerator; cfg_unstable! { mod rt_unstable; } } /// A seed for random number generation. /// /// In order to make certain functions within a runtime deterministic, a seed /// can be specified at the time of creation. #[allow(unreachable_pub)] #[deriv...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
8f0103f6c5fd300fee15888fc15ec9dd86248690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f0103f6c5fd300fee15888fc15ec9dd86248690/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; cfg_rt! { use std::sync::Mutex; /// A deterministic generator for seeds (and other generators). /// /// Given the same initial seed, the generator will output the same sequence of seeds. /// /// Since the seed generator will be kept in a runtime handle, we need to wrap `Fa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
b921fe45ac9fc49e18bc6e834065b61d246f56e0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b921fe45ac9fc49e18bc6e834065b61d246f56e0/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:2
/// Directly creates a generator using the next seed. pub(crate) fn next_generator(&self) -> Self { RngSeedGenerator::new(self.next_seed()) } } } /// A seed for random number generation. /// /// In order to make certain functions within a runtime deterministic, a seed /// can be specifi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
b921fe45ac9fc49e18bc6e834065b61d246f56e0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b921fe45ac9fc49e18bc6e834065b61d246f56e0/tokio/src/util/rand.rs
41
100
tokio-rs/tokio:tokio/src/util/rand.rs:3
Self::from_u64(hasher.finish()) } } fn from_u64(seed: u64) -> Self { let one = (seed >> 32) as u32; let mut two = seed as u32; if two == 0 { // This value cannot be zero two = 1; } Self::from_pair(one, two) } fn from_pair(s: u32...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
b921fe45ac9fc49e18bc6e834065b61d246f56e0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b921fe45ac9fc49e18bc6e834065b61d246f56e0/tokio/src/util/rand.rs
81
140
tokio-rs/tokio:tokio/src/util/rand.rs:4
} /// Replaces the state of the random number generator with the provided seed, returning /// the seed that represents the previous state of the random number generator. /// /// The random number generator will become equivalent to one created with /// the same seed. #[cfg(feature = "rt")] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
b921fe45ac9fc49e18bc6e834065b61d246f56e0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b921fe45ac9fc49e18bc6e834065b61d246f56e0/tokio/src/util/rand.rs
121
162
tokio-rs/tokio:tokio/src/util/rand.rs:3
Self::from_u64(hasher.finish()) } } fn from_u64(seed: u64) -> Self { let one = (seed >> 32) as u32; let mut two = seed as u32; if two == 0 { // This value cannot be zero two = 1; } Self::from_pair(one, two) } fn from_pair(s: u32...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
87510100cebd7e2525e1a081c6a526ac95cf7967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/87510100cebd7e2525e1a081c6a526ac95cf7967/tokio/src/util/rand.rs
81
140
tokio-rs/tokio:tokio/src/util/rand.rs:4
} /// Replaces the state of the random number generator with the provided seed, returning /// the seed that represents the previous state of the random number generator. /// /// The random number generator will become equivalent to one created with /// the same seed. #[cfg(feature = "rt")] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
87510100cebd7e2525e1a081c6a526ac95cf7967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/87510100cebd7e2525e1a081c6a526ac95cf7967/tokio/src/util/rand.rs
121
158
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; cfg_rt! { use std::sync::Mutex; /// A deterministic generator for seeds (and other generators). /// /// Given the same initial seed, the generator will output the same sequence of seeds. /// /// Since the seed generator will be kept in a runtime handle, we need to wrap `Fa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
df99428c17ff03134d8f081ee80ef0f6fbe3c813
github
async-runtime
https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:2
/// Directly creates a generator using the next seed. pub(crate) fn next_generator(&self) -> Self { RngSeedGenerator::new(self.next_seed()) } } } /// A seed for random numnber generation. /// /// In order to make certain functions within a runtime deterministic, a seed /// can be specif...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
df99428c17ff03134d8f081ee80ef0f6fbe3c813
github
async-runtime
https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/util/rand.rs
41
100
tokio-rs/tokio:tokio/src/util/rand.rs:4
} /// Replaces the state of the random number generator with the provided seed, returning /// the seed that represents the previous state of the random number generator. /// /// The random number generator will become equivalent to one created with /// the same seed. #[cfg(feature = "rt")] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/util/rand.rs
121
180
tokio-rs/tokio:tokio/src/util/rand.rs:5
static THREAD_RNG: FastRand = FastRand::new(RngSeed::new()); } /// Seeds the thread local random number generator with the provided seed and /// return the previously stored seed. /// /// The returned seed can be later used to return the thread local random number /// generator to its previous state. #[cfg(feature = "...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/util/rand.rs
161
180
tokio-rs/tokio:tokio/src/util/rand.rs:4
} /// Replaces the state of the random number generator with the provided seed, returning /// the seed that represents the previous state of the random number generator. /// /// The random number generator will become equivalent to one created with /// the same seed. #[cfg(feature = "rt")] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
b5709baa917494043e21589adb10347c57361f1f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5709baa917494043e21589adb10347c57361f1f/tokio/src/util/rand.rs
121
180
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; /// Fast random number generate. /// /// Implement xorshift64+: 2 32-bit xorshift sequences added together. /// Shift triplet `[17,7,16]` was calculated as indicated in Marsaglia's /// Xorshift paper: <https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf> /// This generator passes the Small...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:2
let mut s1 = self.one.get(); let s0 = self.two.get(); s1 ^= s1 << 17; s1 = s1 ^ s0 ^ s1 >> 7 ^ s0 >> 16; self.one.set(s0); self.two.set(s1); s0.wrapping_add(s1) } } // Used by the select macro and `StreamMap` #[cfg(any(feature = "macros"))] #[doc(hidden)] #[cfg_at...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/rand.rs
41
64
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; /// Fast random number generate /// /// Implement xorshift64+: 2 32-bit xorshift sequences added together. /// Shift triplet `[17,7,16]` was calculated as indicated in Marsaglia's /// Xorshift paper: <https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf> /// This generator passes the SmallC...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
c4b6b130f33532e891e1021381b203f1bbced086
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c4b6b130f33532e891e1021381b203f1bbced086/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; /// Fast random number generate /// /// Implement xorshift64+: 2 32-bit xorshift sequences added together. /// Shift triplet `[17,7,16]` was calculated as indicated in Marsaglia's /// Xorshift paper: https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf /// This generator passes the SmallCru...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
a08ce0d3e06d650361283dc87c8fe14b146df15d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a08ce0d3e06d650361283dc87c8fe14b146df15d/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; /// Fast random number generate /// /// Implement xorshift64+: 2 32-bit xorshift sequences added together. /// Shift triplet [17,7,16] was calculated as indicated in Marsaglia's /// Xorshift paper: https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf /// This generator passes the SmallCrush...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
8efa62013b551d5130791c3a79ce8ab5cb0b5abf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; /// Fast random number generate /// /// Implement xorshift64+: 2 32-bit xorshift sequences added together. /// Shift triplet [17,7,16] was calculated as indicated in Marsaglia's /// Xorshift paper: https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf /// This generator passes the SmallCrush...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
ab24a655adc1eb0d0c6951d5df2b815c671ac7d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ab24a655adc1eb0d0c6951d5df2b815c671ac7d2/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:2
let mut s1 = self.one.get(); let s0 = self.two.get(); s1 ^= s1 << 17; s1 = s1 ^ s0 ^ s1 >> 7 ^ s0 >> 16; self.one.set(s0); self.two.set(s1); s0.wrapping_add(s1) } } // Used by the select macro and `StreamMap` #[cfg(any(feature = "macros", feature = "stream"))] #[d...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
ab24a655adc1eb0d0c6951d5df2b815c671ac7d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ab24a655adc1eb0d0c6951d5df2b815c671ac7d2/tokio/src/util/rand.rs
41
64
tokio-rs/tokio:tokio/src/util/rand.rs:1
use std::cell::Cell; /// Fast random number generate /// /// Implement xorshift64+: 2 32-bit xorshift sequences added together. /// Shift triplet [17,7,16] was calculated as indicated in Marsaglia's /// Xorshift paper: https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf /// This generator passes the SmallCrush...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
8cf98d694663e8397bfc337e7a4676567287bfae
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8cf98d694663e8397bfc337e7a4676567287bfae/tokio/src/util/rand.rs
1
60
tokio-rs/tokio:tokio/src/util/rand.rs:2
let mut s1 = self.one.get(); let s0 = self.two.get(); s1 ^= s1 << 17; s1 = s1 ^ s0 ^ s1 >> 7 ^ s0 >> 16; self.one.set(s0); self.two.set(s1); s0.wrapping_add(s1) } } // Used by the select macro cfg_macros! { thread_local! { static THREAD_RNG: FastRand =...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand.rs
MIT
8cf98d694663e8397bfc337e7a4676567287bfae
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8cf98d694663e8397bfc337e7a4676567287bfae/tokio/src/util/rand.rs
41
65
tokio-rs/tokio:tokio/src/util/rand/rt.rs:1
use super::{FastRand, RngSeed}; use std::sync::Mutex; /// A deterministic generator for seeds (and other generators). /// /// Given the same initial seed, the generator will output the same sequence of seeds. /// /// Since the seed generator will be kept in a runtime handle, we need to wrap `FastRand` /// in a Mutex ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand/rt.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/rand/rt.rs
1
60
tokio-rs/tokio:tokio/src/util/rand/rt.rs:2
/// Directly creates a generator using the next seed. pub(crate) fn next_generator(&self) -> Self { RngSeedGenerator::new(self.next_seed()) } } impl FastRand { /// Replaces the state of the random number generator with the provided seed, returning /// the seed that represents the previous state...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand/rt.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/rand/rt.rs
41
61
tokio-rs/tokio:tokio/src/util/rand/rt_unstable.rs:1
use super::RngSeed; use std::collections::hash_map::DefaultHasher; use std::hash::Hasher; impl RngSeed { /// Generates a seed from the provided byte slice. /// /// # Example /// /// ``` /// # use tokio::runtime::RngSeed; /// let seed = RngSeed::from_bytes(b"make me a seed"); /// ``` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rand/rt_unstable.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/rand/rt_unstable.rs
1
20
tokio-rs/tokio:tokio/src/util/rc_cell.rs:1
use crate::loom::cell::UnsafeCell; use std::rc::Rc; /// This is exactly like `Cell<Option<Rc<T>>>`, except that it provides a `get` /// method even though `Rc` is not `Copy`. pub(crate) struct RcCell<T> { inner: UnsafeCell<Option<Rc<T>>>, } impl<T> RcCell<T> { #[cfg(not(all(loom, test)))] pub(crate) cons...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rc_cell.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/rc_cell.rs
1
57
tokio-rs/tokio:tokio/src/util/rc_cell.rs:1
use crate::loom::cell::UnsafeCell; use std::rc::Rc; /// This is exactly like `Cell<Option<Rc<T>>>`, except that it provides a `get` /// method even though `Rc` is not `Copy`. pub(crate) struct RcCell<T> { inner: UnsafeCell<Option<Rc<T>>>, } impl<T> RcCell<T> { #[cfg(not(all(loom, test)))] pub(crate) cons...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rc_cell.rs
MIT
f8097437dde60e9478e3f38302ac28bf5bc3f3f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f8097437dde60e9478e3f38302ac28bf5bc3f3f5/tokio/src/util/rc_cell.rs
1
57
tokio-rs/tokio:tokio/src/util/rc_cell.rs:1
use crate::loom::cell::UnsafeCell; use std::rc::Rc; /// This is exactly like `Cell<Option<Rc<T>>>`, except that it provides a `get` /// method even though `Rc` is not `Copy`. pub(crate) struct RcCell<T> { inner: UnsafeCell<Option<Rc<T>>>, } impl<T> RcCell<T> { #[cfg(not(loom))] pub(crate) const fn new() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/rc_cell.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/util/rc_cell.rs
1
57
tokio-rs/tokio:tokio/src/util/sharded_list.rs:1
use std::ptr::NonNull; use std::sync::atomic::Ordering; use crate::loom::sync::{Mutex, MutexGuard}; use crate::util::metric_atomics::{MetricAtomicU64, MetricAtomicUsize}; use super::linked_list::{Link, LinkedList}; /// An intrusive linked list supporting highly concurrent updates. /// /// It currently relies on `Lin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/sharded_list.rs
1
60
tokio-rs/tokio:tokio/src/util/sharded_list.rs:2
let lists = std::iter::repeat_with(|| Mutex::new(LinkedList::new())); Self { lists: lists.take(sharded_size).collect(), added: MetricAtomicU64::new(0), count: MetricAtomicUsize::new(0), shard_mask, } } } /// Used to get the lock of shard. pub(crate) s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/sharded_list.rs
41
100
tokio-rs/tokio:tokio/src/util/sharded_list.rs:3
let mut lock = self.shard_inner(id); // SAFETY: Since the shard id cannot change, it's not possible for this node // to be in any other list of the same sharded list. let node = unsafe { lock.remove(node) }; if node.is_some() { self.count.decrement(); } node ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/sharded_list.rs
81
140
tokio-rs/tokio:tokio/src/util/sharded_list.rs:4
/// Gets the shard size of this `SharedList`. /// /// Used to help us to decide the parameter `shard_id` of the `pop_back` method. pub(crate) fn shard_size(&self) -> usize { self.shard_mask + 1 } #[inline] fn shard_inner(&self, id: usize) -> MutexGuard<'_, LinkedList<L, <L as Link>::Tar...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/util/sharded_list.rs
121
161
tokio-rs/tokio:tokio/src/util/sharded_list.rs:1
use std::ptr::NonNull; use std::sync::atomic::Ordering; use crate::loom::sync::{Mutex, MutexGuard}; use crate::util::metric_atomics::{MetricAtomicU64, MetricAtomicUsize}; use super::linked_list::{Link, LinkedList}; /// An intrusive linked list supporting highly concurrent updates. /// /// It currently relies on `Lin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
426a56278017c30e7da7b4c9365a2610f4695f76
github
async-runtime
https://github.com/tokio-rs/tokio/blob/426a56278017c30e7da7b4c9365a2610f4695f76/tokio/src/util/sharded_list.rs
1
60
tokio-rs/tokio:tokio/src/util/sharded_list.rs:2
let mut lists = Vec::with_capacity(sharded_size); for _ in 0..sharded_size { lists.push(Mutex::new(LinkedList::<L, T>::new())) } Self { lists: lists.into_boxed_slice(), added: MetricAtomicU64::new(0), count: MetricAtomicUsize::new(0), s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
426a56278017c30e7da7b4c9365a2610f4695f76
github
async-runtime
https://github.com/tokio-rs/tokio/blob/426a56278017c30e7da7b4c9365a2610f4695f76/tokio/src/util/sharded_list.rs
41
100
tokio-rs/tokio:tokio/src/util/sharded_list.rs:3
/// - `node` is currently contained by some other `GuardedLinkedList`. pub(crate) unsafe fn remove(&self, node: NonNull<L::Target>) -> Option<L::Handle> { let id = unsafe { L::get_shard_id(node) }; let mut lock = self.shard_inner(id); // SAFETY: Since the shard id cannot change, it's not pos...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
426a56278017c30e7da7b4c9365a2610f4695f76
github
async-runtime
https://github.com/tokio-rs/tokio/blob/426a56278017c30e7da7b4c9365a2610f4695f76/tokio/src/util/sharded_list.rs
81
140
tokio-rs/tokio:tokio/src/util/sharded_list.rs:4
self.len() == 0 } /// Gets the shard size of this `SharedList`. /// /// Used to help us to decide the parameter `shard_id` of the `pop_back` method. pub(crate) fn shard_size(&self) -> usize { self.shard_mask + 1 } #[inline] fn shard_inner(&self, id: usize) -> MutexGuard<'_, Lin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
426a56278017c30e7da7b4c9365a2610f4695f76
github
async-runtime
https://github.com/tokio-rs/tokio/blob/426a56278017c30e7da7b4c9365a2610f4695f76/tokio/src/util/sharded_list.rs
121
164
tokio-rs/tokio:tokio/src/util/sharded_list.rs:3
/// - `node` is currently contained by some other `GuardedLinkedList`. pub(crate) unsafe fn remove(&self, node: NonNull<L::Target>) -> Option<L::Handle> { let id = unsafe { L::get_shard_id(node) }; let mut lock = self.shard_inner(id); // SAFETY: Since the shard id cannot change, it's not pos...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/util/sharded_list.rs
81
140
tokio-rs/tokio:tokio/src/util/sharded_list.rs:1
use std::ptr::NonNull; use std::sync::atomic::Ordering; use crate::loom::sync::{Mutex, MutexGuard}; use crate::util::metric_atomics::{MetricAtomicU64, MetricAtomicUsize}; use super::linked_list::{Link, LinkedList}; /// An intrusive linked list supporting highly concurrent updates. /// /// It currently relies on `Lin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
9a75d6f7f70fd81f589a8209c548944bc3d05f84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a75d6f7f70fd81f589a8209c548944bc3d05f84/tokio/src/util/sharded_list.rs
1
60
tokio-rs/tokio:tokio/src/util/sharded_list.rs:2
for _ in 0..sharded_size { lists.push(Mutex::new(LinkedList::<L, T>::new())) } Self { lists: lists.into_boxed_slice(), added: MetricAtomicU64::new(0), count: MetricAtomicUsize::new(0), shard_mask, } } } /// Used to get the lock of ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
9a75d6f7f70fd81f589a8209c548944bc3d05f84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a75d6f7f70fd81f589a8209c548944bc3d05f84/tokio/src/util/sharded_list.rs
41
100
tokio-rs/tokio:tokio/src/util/sharded_list.rs:3
pub(crate) unsafe fn remove(&self, node: NonNull<L::Target>) -> Option<L::Handle> { let id = L::get_shard_id(node); let mut lock = self.shard_inner(id); // SAFETY: Since the shard id cannot change, it's not possible for this node // to be in any other list of the same sharded list. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
9a75d6f7f70fd81f589a8209c548944bc3d05f84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a75d6f7f70fd81f589a8209c548944bc3d05f84/tokio/src/util/sharded_list.rs
81
140
tokio-rs/tokio:tokio/src/util/sharded_list.rs:1
use std::ptr::NonNull; use std::sync::atomic::Ordering; use crate::loom::sync::atomic::AtomicU64; use crate::loom::sync::{Mutex, MutexGuard}; use std::sync::atomic::AtomicUsize; use super::linked_list::{Link, LinkedList}; /// An intrusive linked list supporting highly concurrent updates. /// /// It currently relies ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
341b5daa6e4592d285674de4eb116c928fc9f29c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/341b5daa6e4592d285674de4eb116c928fc9f29c/tokio/src/util/sharded_list.rs
1
60
tokio-rs/tokio:tokio/src/util/sharded_list.rs:2
let mut lists = Vec::with_capacity(sharded_size); for _ in 0..sharded_size { lists.push(Mutex::new(LinkedList::<L, T>::new())) } Self { lists: lists.into_boxed_slice(), added: AtomicU64::new(0), count: AtomicUsize::new(0), shard_mask, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
341b5daa6e4592d285674de4eb116c928fc9f29c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/341b5daa6e4592d285674de4eb116c928fc9f29c/tokio/src/util/sharded_list.rs
41
100
tokio-rs/tokio:tokio/src/util/sharded_list.rs:3
/// - `node` is currently contained by some other `GuardedLinkedList`. pub(crate) unsafe fn remove(&self, node: NonNull<L::Target>) -> Option<L::Handle> { let id = L::get_shard_id(node); let mut lock = self.shard_inner(id); // SAFETY: Since the shard id cannot change, it's not possible for t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
341b5daa6e4592d285674de4eb116c928fc9f29c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/341b5daa6e4592d285674de4eb116c928fc9f29c/tokio/src/util/sharded_list.rs
81
140
tokio-rs/tokio:tokio/src/util/sharded_list.rs:4
/// /// Used to help us to decide the parameter `shard_id` of the `pop_back` method. pub(crate) fn shard_size(&self) -> usize { self.shard_mask + 1 } #[inline] fn shard_inner(&self, id: usize) -> MutexGuard<'_, LinkedList<L, <L as Link>::Target>> { // Safety: This modulo operation e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
341b5daa6e4592d285674de4eb116c928fc9f29c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/341b5daa6e4592d285674de4eb116c928fc9f29c/tokio/src/util/sharded_list.rs
121
160
tokio-rs/tokio:tokio/src/util/sharded_list.rs:1
use std::ptr::NonNull; use std::sync::atomic::Ordering; use crate::loom::sync::{Mutex, MutexGuard}; use std::sync::atomic::AtomicUsize; use super::linked_list::{Link, LinkedList}; /// An intrusive linked list supporting highly concurrent updates. /// /// It currently relies on `LinkedList`, so it is the caller's ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/sharded_list.rs
1
60
tokio-rs/tokio:tokio/src/util/sharded_list.rs:2
lists.push(Mutex::new(LinkedList::<L, T>::new())) } Self { lists: lists.into_boxed_slice(), count: AtomicUsize::new(0), shard_mask, } } } /// Used to get the lock of shard. pub(crate) struct ShardGuard<'a, L, T> { lock: MutexGuard<'a, LinkedList<L, T>...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/sharded_list.rs
41
100
tokio-rs/tokio:tokio/src/util/sharded_list.rs:3
// SAFETY: Since the shard id cannot change, it's not possible for this node // to be in any other list of the same sharded list. let node = unsafe { lock.remove(node) }; if node.is_some() { self.count.fetch_sub(1, Ordering::Relaxed); } node } /// Gets the lo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/sharded_list.rs
81
140
tokio-rs/tokio:tokio/src/util/sharded_list.rs:4
} } impl<'a, L: ShardedListItem> ShardGuard<'a, L, L::Target> { /// Push a value to this shard. pub(crate) fn push(mut self, val: L::Handle) { let id = unsafe { L::get_shard_id(L::as_raw(&val)) }; assert_eq!(id, self.id); self.lock.push_front(val); self.count.fetch_add(1, Orderi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/util/sharded_list.rs
121
149
tokio-rs/tokio:tokio/src/util/sharded_list.rs:1
use std::ptr::NonNull; use std::sync::atomic::Ordering; use crate::loom::sync::{Mutex, MutexGuard}; use std::sync::atomic::AtomicUsize; use super::linked_list::{Link, LinkedList}; /// An intrusive linked list supporting highly concurrent updates. /// /// It currently relies on `LinkedList`, so it is the caller's ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
3a4aef17b2c70d255affa51eb473efcf703896e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/tokio/src/util/sharded_list.rs
1
60
tokio-rs/tokio:tokio/src/util/sharded_list.rs:2
lists.push(Mutex::new(LinkedList::<L, T>::new())) } Self { lists: lists.into_boxed_slice(), count: AtomicUsize::new(0), shard_mask, } } } /// Used to get the lock of shard. pub(crate) struct ShardGuard<'a, L, T> { lock: MutexGuard<'a, LinkedList<L, T>...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
3a4aef17b2c70d255affa51eb473efcf703896e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/tokio/src/util/sharded_list.rs
41
100
tokio-rs/tokio:tokio/src/util/sharded_list.rs:3
// SAFETY: Since the shard id cannot change, it's not possible for this node // to be in any other list of the same sharded list. let node = unsafe { lock.remove(node) }; if node.is_some() { self.count.fetch_sub(1, Ordering::Relaxed); } node } /// Gets the lo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/sharded_list.rs
MIT
3a4aef17b2c70d255affa51eb473efcf703896e4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a4aef17b2c70d255affa51eb473efcf703896e4/tokio/src/util/sharded_list.rs
81
140
tokio-rs/tokio:tokio/src/util/slab.rs:2
/// for using the slab with the I/O driver. Addresses are registered with the /// OS's selector and I/O resources can be released without synchronizing with /// the OS. /// /// # Compaction /// /// `Slab::compact` will release pages that have been allocated but are no /// longer used. This is done by scanning the pages...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
41
100
tokio-rs/tokio:tokio/src/util/slab.rs:3
/// the slot, the generations are compared. If they match, the value matches the /// address. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub(crate) struct Address(usize); /// An entry in the slab. pub(crate) trait Entry: Default { /// Resets the entry's value and track the generation. fn reset(&self); } ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
81
140
tokio-rs/tokio:tokio/src/util/slab.rs:4
} struct CachedPage<T> { /// Pointer to the page's slots. slots: *const Slot<T>, /// Number of initialized slots. init: usize, } /// Page state. struct Slots<T> { /// Slots. slots: Vec<Slot<T>>, head: usize, /// Number of slots currently in use. used: usize, } unsafe impl<T: Sy...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
121
180
tokio-rs/tokio:tokio/src/util/slab.rs:5
/// Makes miri happy by making mutable references not take exclusive access. /// /// Could probably also be fixed by replacing `slots` with a raw-pointer /// based equivalent. _pin: std::marker::PhantomPinned, } /// Value paired with a reference to the page. struct Value<T> { /// Value stored in th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
161
220
tokio-rs/tokio:tokio/src/util/slab.rs:6
// Ensure we don't exceed the max address space. debug_assert!( page.len - 1 + page.prev_len < (1 << 24), "max = {:b}", page.len - 1 + page.prev_len ); } slab } /// Returns a new `Allocator`. /// /// The `Allocator...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
201
260
tokio-rs/tokio:tokio/src/util/slab.rs:7
// Get a reference to the value. The lifetime of the returned reference // is bound to `&self`. The only way to invalidate the underlying memory // is to call `compact()`. The lifetimes prevent calling `compact()` // while references to values are outstanding. // // The reference...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
241
300
tokio-rs/tokio:tokio/src/util/slab.rs:8
for (idx, page) in self.pages.iter().enumerate().skip(1) { if page.used.load(Relaxed) != 0 || !page.allocated.load(Relaxed) { // If the page has slots in use or the memory has not been // allocated then it cannot be compacted. continue; } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
281
340
tokio-rs/tokio:tokio/src/util/slab.rs:9
drop(vec); } } } impl<T> fmt::Debug for Slab<T> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { debug(fmt, "Slab", &self.pages[..]) } } impl<T: Entry> Allocator<T> { /// Allocate a new entry and return a handle to the entry. /// /// Scans pages from smallest to b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
321
380
tokio-rs/tokio:tokio/src/util/slab.rs:10
fn deref(&self) -> &T { // Safety: `&mut` is never handed out to the underlying value. The page // is not freed until all `Ref` values are dropped. unsafe { &(*self.value).value } } } impl<T> Drop for Ref<T> { fn drop(&mut self) { // Safety: `&mut` is never handed out to the und...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
361
420
tokio-rs/tokio:tokio/src/util/slab.rs:11
// Get the index of the slot at the head of the free stack. This is // the slot that will be reused. let idx = locked.head; let slot = &locked.slots[idx]; // Update the free stack head to point to the next slot. locked.head = slot.next as usize; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
401
460
tokio-rs/tokio:tokio/src/util/slab.rs:12
}); // Increment the head to indicate the free stack is empty locked.head += 1; // Increment the number of used slots locked.used += 1; me.used.store(locked.used, Relaxed); me.allocated.store(true, Relaxed); debug_assert_eq!(locked.s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
441
500
tokio-rs/tokio:tokio/src/util/slab.rs:13
len: 0, prev_len: 0, } } } impl<T> Page<T> { /// Release a slot into the page's free list. fn release(&self, value: *const Value<T>) { let mut locked = self.slots.lock(); let idx = locked.index_for(value); locked.slots[idx].next = locked.head as u32; loc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
481
540
tokio-rs/tokio:tokio/src/util/slab.rs:14
// `CachedPage`. unsafe { let slot = self.slots.add(idx); let value = slot as *const Value<T>; &(*value).value } } } impl<T> Default for CachedPage<T> { fn default() -> CachedPage<T> { CachedPage { slots: ptr::null(), init: 0,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
521
580
tokio-rs/tokio:tokio/src/util/slab.rs:15
let idx = (slot - base) / width; assert!(idx < self.slots.len()); idx } /// Generates a `Ref` for the slot at the given index. This involves bumping the page's ref count. fn gen_ref(&self, idx: usize, page: &Arc<Page<T>>) -> Ref<T> { assert!(idx < self.slots.len()); mem::fo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
561
620
tokio-rs/tokio:tokio/src/util/slab.rs:16
// bits in a word. let slot_shifted = (self.0 + PAGE_INITIAL_SIZE) >> PAGE_INDEX_SHIFT; (bit::pointer_width() - slot_shifted.leading_zeros()) as usize } pub(crate) const fn as_usize(self) -> usize { self.0 } pub(crate) fn from_usize(src: usize) -> Address { Address(src)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
601
660
tokio-rs/tokio:tokio/src/util/slab.rs:17
} impl Default for Foo { fn default() -> Foo { Foo { cnt: AtomicUsize::new(0), id: AtomicUsize::new(0), } } } impl Entry for Foo { fn reset(&self) { self.cnt.fetch_add(1, SeqCst); } } #[test] f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
641
700
tokio-rs/tokio:tokio/src/util/slab.rs:18
foo3.id.store(3, SeqCst); assert_eq!(3, slab.get(addr3).unwrap().id.load(SeqCst)); drop(foo2); drop(foo3); slab.compact(); // The first page is never released assert!(slab.get(addr1).is_some()); assert!(slab.get(addr2).is_some()); assert!(slab.get(addr3...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
681
740
tokio-rs/tokio:tokio/src/util/slab.rs:19
for (i, (addr, v)) in entries.iter().enumerate() { assert_eq!(MANY - i, v.id.load(SeqCst)); assert_eq!(MANY - i, slab.get(*addr).unwrap().id.load(SeqCst)); } } #[test] fn insert_drop_reverse() { let mut slab = Slab::<Foo>::new(); let alloc = slab.allocator();...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
721
780
tokio-rs/tokio:tokio/src/util/slab.rs:20
for i in 0..normal_or_miri(10_000, 100) { let (addr, val) = alloc.allocate().unwrap(); val.id.store(i, SeqCst); if i % 2 == 0 { entries1.push((addr, val, i)); } else { entries2.push(val); } } drop(entries2); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
761
820
tokio-rs/tokio:tokio/src/util/slab.rs:21
} let mut addrs = vec![]; for (addr, _) in entries.drain(..) { addrs.push(addr); } slab.compact(); // The first page is never freed for addr in &addrs[PAGE_INITIAL_SIZE..] { assert!(slab.get(*addr).is_none()); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
801
854
tokio-rs/tokio:tokio/src/util/slab.rs:22
entries.pop(); // Compact slab.compact(); // Check all the addresses for (addr, val, i) in &entries { assert_eq!(*i, val.id.load(SeqCst)); assert_eq!(*i, slab.get(*addr).unwrap().id.load(SeqCst)); } } } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
0c8e8248f8de281f22ad6f30b967053f44fff66e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/src/util/slab.rs
841
854
tokio-rs/tokio:tokio/src/util/slab.rs:14
// `CachedPage`. unsafe { let slot = self.slots.add(idx); let value = slot as *const Value<T>; &(*value).value } } } impl<T> Default for CachedPage<T> { fn default() -> CachedPage<T> { CachedPage { slots: ptr::null(), init: 0,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
cc6c2f40cb1f54a6f53157a7631ac075130c7e36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cc6c2f40cb1f54a6f53157a7631ac075130c7e36/tokio/src/util/slab.rs
521
580
tokio-rs/tokio:tokio/src/util/slab.rs:15
let idx = (slot - base) / width; assert!(idx < self.slots.len() as usize); idx } /// Generates a `Ref` for the slot at the given index. This involves bumping the page's ref count. fn gen_ref(&self, idx: usize, page: &Arc<Page<T>>) -> Ref<T> { assert!(idx < self.slots.len()); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
cc6c2f40cb1f54a6f53157a7631ac075130c7e36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cc6c2f40cb1f54a6f53157a7631ac075130c7e36/tokio/src/util/slab.rs
561
620
tokio-rs/tokio:tokio/src/util/slab.rs:14
// `CachedPage`. unsafe { let slot = self.slots.add(idx); let value = slot as *const Value<T>; &(*value).value } } } impl<T> Default for CachedPage<T> { fn default() -> CachedPage<T> { CachedPage { slots: ptr::null(), init: 0,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
521
580
tokio-rs/tokio:tokio/src/util/slab.rs:15
assert!(slot >= base, "unexpected pointer"); let idx = (slot - base) / width; assert!(idx < self.slots.len() as usize); idx } /// Generates a `Ref` for the slot at the given index. This involves bumping the page's ref count. fn gen_ref(&self, idx: usize, page: &Arc<Page<T>>) -> Re...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
561
620
tokio-rs/tokio:tokio/src/util/slab.rs:16
// representation, and subtracting that count from the total number of // bits in a word. let slot_shifted = (self.0 + PAGE_INITIAL_SIZE) >> PAGE_INDEX_SHIFT; (bit::pointer_width() - slot_shifted.leading_zeros()) as usize } pub(crate) const fn as_usize(self) -> usize { self.0 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
601
660
tokio-rs/tokio:tokio/src/util/slab.rs:17
id: AtomicUsize, } impl Default for Foo { fn default() -> Foo { Foo { cnt: AtomicUsize::new(0), id: AtomicUsize::new(0), } } } impl Entry for Foo { fn reset(&self) { self.cnt.fetch_add(1, SeqCst); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
641
700
tokio-rs/tokio:tokio/src/util/slab.rs:18
assert_eq!(1, foo3.cnt.load(SeqCst)); foo3.id.store(3, SeqCst); assert_eq!(3, slab.get(addr3).unwrap().id.load(SeqCst)); drop(foo2); drop(foo3); slab.compact(); // The first page is never released assert!(slab.get(addr1).is_some()); assert!(slab.get(add...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
681
740
tokio-rs/tokio:tokio/src/util/slab.rs:19
} for (i, (addr, v)) in entries.iter().enumerate() { assert_eq!(MANY - i, v.id.load(SeqCst)); assert_eq!(MANY - i, slab.get(*addr).unwrap().id.load(SeqCst)); } } #[test] fn insert_drop_reverse() { let mut slab = Slab::<Foo>::new(); let alloc = slab.a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
721
780
tokio-rs/tokio:tokio/src/util/slab.rs:20
for i in 0..normal_or_miri(10_000, 100) { let (addr, val) = alloc.allocate().unwrap(); val.id.store(i, SeqCst); if i % 2 == 0 { entries1.push((addr, val, i)); } else { entries2.push(val); } } drop(entries2); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
761
820
tokio-rs/tokio:tokio/src/util/slab.rs:21
entries.push((addr, val)); } let mut addrs = vec![]; for (addr, _) in entries.drain(..) { addrs.push(addr); } slab.compact(); // The first page is never freed for addr in &addrs[PAGE_INITIAL_SIZE..] { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
801
855
tokio-rs/tokio:tokio/src/util/slab.rs:22
// Release the last entry entries.pop(); // Compact slab.compact(); // Check all the addresses for (addr, val, i) in &entries { assert_eq!(*i, val.id.load(SeqCst)); assert_eq!(*i, slab.get(*addr).unwrap().id.load(SeqCst)); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/util/slab.rs
841
855
tokio-rs/tokio:tokio/src/util/slab.rs:4
} struct CachedPage<T> { /// Pointer to the page's slots. slots: *const Slot<T>, /// Number of initialized slots. init: usize, } /// Page state. struct Slots<T> { /// Slots. slots: Vec<Slot<T>>, head: usize, /// Number of slots currently in use. used: usize, } unsafe impl<T: Sy...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
121
180
tokio-rs/tokio:tokio/src/util/slab.rs:5
/// Value paired with a reference to the page. struct Value<T> { /// Value stored in the value. value: T, /// Pointer to the page containing the slot. /// /// A raw pointer is used as this creates a ref cycle. page: *const Page<T>, } impl<T> Slab<T> { /// Create a new, empty, slab. pub...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
161
220
tokio-rs/tokio:tokio/src/util/slab.rs:6
} slab } /// Returns a new `Allocator`. /// /// The `Allocator` supports concurrent allocation of objects. pub(crate) fn allocator(&self) -> Allocator<T> { Allocator { pages: self.pages.clone(), } } /// Returns a reference to the value stored at the giv...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
201
260
tokio-rs/tokio:tokio/src/util/slab.rs:7
// used and the data is `Sync`. Some(self.cached[page_idx].get(slot_idx)) } /// Calls the given function with a reference to each slot in the slab. The /// slot may not be in-use. /// /// This is used by the I/O driver during the shutdown process to notify /// each pending task. pub...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
241
300
tokio-rs/tokio:tokio/src/util/slab.rs:8
let mut slots = match page.slots.try_lock() { Some(slots) => slots, // If the lock cannot be acquired due to being held by another // thread, don't try to compact the page. _ => continue, }; if slots.used > 0 || slots.slots.capacit...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
281
340
tokio-rs/tokio:tokio/src/util/slab.rs:9
impl<T> fmt::Debug for Slab<T> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { debug(fmt, "Slab", &self.pages[..]) } } impl<T: Entry> Allocator<T> { /// Allocate a new entry and return a handle to the entry. /// /// Scans pages from smallest to biggest, stopping when a slot i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
321
380
tokio-rs/tokio:tokio/src/util/slab.rs:10
impl<T> Drop for Ref<T> { fn drop(&mut self) { // Safety: `&mut` is never handed out to the underlying value. The page // is not freed until all `Ref` values are dropped. let _ = unsafe { (*self.value).release() }; } } impl<T: fmt::Debug> fmt::Debug for Ref<T> { fn fmt(&self, fmt: &...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
361
420
tokio-rs/tokio:tokio/src/util/slab.rs:11
// Update the free stack head to point to the next slot. locked.head = slot.next as usize; // Increment the number of used slots locked.used += 1; me.used.store(locked.used, Relaxed); // Reset the slot slot.value.with(|ptr| unsafe { (*ptr).value....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
401
460
tokio-rs/tokio:tokio/src/util/slab.rs:12
me.used.store(locked.used, Relaxed); me.allocated.store(true, Relaxed); debug_assert_eq!(locked.slots.len(), locked.head); Some((me.addr(idx), locked.slots[idx].gen_ref(me))) } } } impl<T> Page<T> { /// Returns the slot index within the current page referenced by t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/util/slab.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/util/slab.rs
441
500