Skip to content

Commit

Permalink
Remove RwLockMappedReadGuard again
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Dec 25, 2020
1 parent e418a80 commit 3037ff1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 166 deletions.
1 change: 0 additions & 1 deletion tokio/src/sync/mod.rs
Expand Up @@ -452,7 +452,6 @@ cfg_sync! {
mod rwlock;
pub use rwlock::RwLock;
pub use rwlock::read_guard::RwLockReadGuard;
pub use rwlock::read_guard_mapped::RwLockMappedReadGuard;
pub use rwlock::write_guard::RwLockWriteGuard;
pub use rwlock::write_guard_mapped::RwLockMappedWriteGuard;

Expand Down
4 changes: 0 additions & 4 deletions tokio/src/sync/rwlock.rs
Expand Up @@ -3,11 +3,9 @@ use std::cell::UnsafeCell;
use std::marker;

pub(crate) mod read_guard;
pub(crate) mod read_guard_mapped;
pub(crate) mod write_guard;
pub(crate) mod write_guard_mapped;
pub(crate) use read_guard::RwLockReadGuard;
pub(crate) use read_guard_mapped::RwLockMappedReadGuard;
pub(crate) use write_guard::RwLockWriteGuard;
pub(crate) use write_guard_mapped::RwLockMappedWriteGuard;

Expand Down Expand Up @@ -120,9 +118,7 @@ unsafe impl<T> Sync for RwLock<T> where T: ?Sized + Send + Sync {}
// Safety: Stores a raw pointer to `T`, so if `T` is `Sync`, the lock guard over
// `T` is `Send`.
unsafe impl<T> Send for RwLockReadGuard<'_, T> where T: ?Sized + Sync {}
unsafe impl<T> Send for RwLockMappedReadGuard<'_, T> where T: ?Sized + Sync {}
unsafe impl<T> Sync for RwLockReadGuard<'_, T> where T: ?Sized + Send + Sync {}
unsafe impl<T> Sync for RwLockMappedReadGuard<'_, T> where T: ?Sized + Send + Sync {}
unsafe impl<T> Sync for RwLockWriteGuard<'_, T> where T: ?Sized + Send + Sync {}
unsafe impl<T> Sync for RwLockMappedWriteGuard<'_, T> where T: ?Sized + Send + Sync {}
// Safety: Stores a raw pointer to `T`, so if `T` is `Sync`, the lock guard over
Expand Down
9 changes: 4 additions & 5 deletions tokio/src/sync/rwlock/read_guard.rs
@@ -1,5 +1,4 @@
use crate::sync::batch_semaphore::Semaphore;
use crate::sync::rwlock::read_guard_mapped::RwLockMappedReadGuard;
use std::fmt;
use std::marker;
use std::mem;
Expand Down Expand Up @@ -54,15 +53,15 @@ impl<'a, T> RwLockReadGuard<'a, T> {
/// # }
/// ```
#[inline]
pub fn map<F, U: ?Sized>(this: Self, f: F) -> RwLockMappedReadGuard<'a, U>
pub fn map<F, U: ?Sized>(this: Self, f: F) -> RwLockReadGuard<'a, U>
where
F: FnOnce(&T) -> &U,
{
let data = f(&*this) as *const U;
let s = this.s;
// NB: Forget to avoid drop impl from being called.
mem::forget(this);
RwLockMappedReadGuard {
RwLockReadGuard {
s,
data,
marker: marker::PhantomData,
Expand Down Expand Up @@ -105,7 +104,7 @@ impl<'a, T> RwLockReadGuard<'a, T> {
/// # }
/// ```
#[inline]
pub fn try_map<F, U: ?Sized>(this: Self, f: F) -> Result<RwLockMappedReadGuard<'a, U>, Self>
pub fn try_map<F, U: ?Sized>(this: Self, f: F) -> Result<RwLockReadGuard<'a, U>, Self>
where
F: FnOnce(&T) -> Option<&U>,
{
Expand All @@ -116,7 +115,7 @@ impl<'a, T> RwLockReadGuard<'a, T> {
let s = this.s;
// NB: Forget to avoid drop impl from being called.
mem::forget(this);
Ok(RwLockMappedReadGuard {
Ok(RwLockReadGuard {
s,
data,
marker: marker::PhantomData,
Expand Down
156 changes: 0 additions & 156 deletions tokio/src/sync/rwlock/read_guard_mapped.rs

This file was deleted.

0 comments on commit 3037ff1

Please sign in to comment.