mirror of https://github.com/xacrimon/dashmap
Added some inline attribs.
This commit is contained in:
parent
b46b4ce5b0
commit
264c364033
|
@ -78,6 +78,7 @@ where
|
|||
K: Eq + Hash,
|
||||
S: Default + BuildHasher + Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self::with_hasher(Default::default())
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
|
|||
}
|
||||
|
||||
impl<T: ?Sized + Default> Default for RwLock<T> {
|
||||
#[inline]
|
||||
fn default() -> RwLock<T> {
|
||||
RwLock::new(Default::default())
|
||||
}
|
||||
|
@ -255,6 +256,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> {
|
|||
impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T> {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &T {
|
||||
unsafe { self.data.as_ref() }
|
||||
}
|
||||
|
@ -263,6 +265,7 @@ impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T> {
|
|||
impl<'rwlock, T: ?Sized> Deref for RwLockUpgradeableGuard<'rwlock, T> {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &T {
|
||||
unsafe { self.data.as_ref() }
|
||||
}
|
||||
|
@ -271,18 +274,21 @@ impl<'rwlock, T: ?Sized> Deref for RwLockUpgradeableGuard<'rwlock, T> {
|
|||
impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T> {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &T {
|
||||
unsafe { self.data.as_ref() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'rwlock, T: ?Sized> DerefMut for RwLockWriteGuard<'rwlock, T> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut T {
|
||||
unsafe { self.data.as_mut() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'rwlock, T: ?Sized> Drop for RwLockReadGuard<'rwlock, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
debug_assert!(self.lock.load(Ordering::Relaxed) & !(WRITER | UPGRADED) > 0);
|
||||
self.lock.fetch_sub(READER, Ordering::Release);
|
||||
|
@ -290,6 +296,7 @@ impl<'rwlock, T: ?Sized> Drop for RwLockReadGuard<'rwlock, T> {
|
|||
}
|
||||
|
||||
impl<'rwlock, T: ?Sized> Drop for RwLockUpgradeableGuard<'rwlock, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
debug_assert_eq!(
|
||||
self.lock.load(Ordering::Relaxed) & (WRITER | UPGRADED),
|
||||
|
@ -300,6 +307,7 @@ impl<'rwlock, T: ?Sized> Drop for RwLockUpgradeableGuard<'rwlock, T> {
|
|||
}
|
||||
|
||||
impl<'rwlock, T: ?Sized> Drop for RwLockWriteGuard<'rwlock, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
debug_assert_eq!(self.lock.load(Ordering::Relaxed) & WRITER, WRITER);
|
||||
self.lock.fetch_and(!(WRITER | UPGRADED), Ordering::Release);
|
||||
|
|
|
@ -67,6 +67,7 @@ unsafe impl<T: Sync> Sync for SharedValue<T> {}
|
|||
|
||||
impl<T> SharedValue<T> {
|
||||
/// Create a new `SharedValue<T>`
|
||||
#[inline]
|
||||
pub const fn new(value: T) -> Self {
|
||||
Self {
|
||||
value: UnsafeCell::new(value),
|
||||
|
@ -74,21 +75,25 @@ impl<T> SharedValue<T> {
|
|||
}
|
||||
|
||||
/// Get a shared reference to `T`
|
||||
#[inline]
|
||||
pub fn get(&self) -> &T {
|
||||
unsafe { &*self.value.get() }
|
||||
}
|
||||
|
||||
/// Get an unique reference to `T`
|
||||
#[inline]
|
||||
pub fn get_mut(&mut self) -> &mut T {
|
||||
unsafe { &mut *self.value.get() }
|
||||
}
|
||||
|
||||
/// Unwraps the value
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> T {
|
||||
self.value.into_inner()
|
||||
}
|
||||
|
||||
/// Get a mutable raw pointer to the underlying value
|
||||
#[inline]
|
||||
pub(crate) fn as_ptr(&self) -> *mut T {
|
||||
self.value.get()
|
||||
}
|
||||
|
@ -97,6 +102,7 @@ impl<T> SharedValue<T> {
|
|||
struct AbortOnPanic;
|
||||
|
||||
impl Drop for AbortOnPanic {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
if std::thread::panicking() {
|
||||
std::process::abort()
|
||||
|
|
Loading…
Reference in New Issue