[−][src]Struct crossbeam::sync::ShardedLock
A scalable reader-writer lock.
This type of lock allows a number of readers or at most one writer at any point in time. The write portion of this lock typically allows modification of the underlying data (exclusive access) and the read portion of this lock typically allows for read-only access (shared access).
This reader-writer lock differs from typical implementations in that it internally creates a list of reader-writer locks called 'shards'. Shards are aligned and padded to the cache line size.
Read operations lock only one shard specific to the current thread, while write operations lock every shard in succession. This strategy makes concurrent read operations faster due to less contention, but write operations are slower due to increased amount of locking.
Methods
impl<T> ShardedLock<T>
[src]
impl<T> ShardedLock<T>
pub fn new(value: T) -> ShardedLock<T>
[src]
pub fn new(value: T) -> ShardedLock<T>
Creates a new ShardedLock
initialized with value
.
pub fn read(&self) -> ShardedLockReadGuard<T>
[src]
pub fn read(&self) -> ShardedLockReadGuard<T>
Locks with shared read access, blocking the current thread until it can be acquired.
The calling thread will be blocked until there are no more writers which hold the lock. There may be other readers currently inside the lock when this method returns. This method does not provide any guarantees with respect to the ordering of whether contentious readers or writers will acquire the lock first.
Returns an RAII guard which will drop the read access of this lock when dropped.
pub fn write(&self) -> ShardedLockWriteGuard<T>
[src]
pub fn write(&self) -> ShardedLockWriteGuard<T>
Locks with exclusive write access, blocking the current thread until it can be acquired.
This function will not return while other writers or other readers currently have access to the lock.
Returns an RAII guard which will drop the write access of this lock when dropped.
Trait Implementations
impl<T: Send> Send for ShardedLock<T>
[src]
impl<T: Send> Send for ShardedLock<T>
impl<T: Send + Sync> Sync for ShardedLock<T>
[src]
impl<T: Send + Sync> Sync for ShardedLock<T>
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
ⓘImportant traits for &'a mut Wfn borrow(&self) -> &T
[src]
fn borrow(&self) -> &T
Immutably borrows from an owned value. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
ⓘImportant traits for &'a mut Wfn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
[src]
impl<T> Erased for T