Fix a couple of dead code warnings
This commit is contained in:
+8
-24
@@ -169,7 +169,7 @@ pub unsafe fn deallocate_p2frame(orig_frame: Frame, order: u32) {
|
||||
break;
|
||||
};
|
||||
|
||||
let PageInfoKind::Free(sib_info) = sib_info.kind() else {
|
||||
let Some(sib_info) = sib_info.as_free() else {
|
||||
// The frame is currently in use (refcounted). It cannot be merged!
|
||||
break;
|
||||
};
|
||||
@@ -416,14 +416,6 @@ pub struct PageInfo {
|
||||
pub next: AtomicUsize,
|
||||
}
|
||||
|
||||
enum PageInfoKind<'info> {
|
||||
Used(PageInfoUsed<'info>),
|
||||
Free(PageInfoFree<'info>),
|
||||
}
|
||||
struct PageInfoUsed<'info> {
|
||||
_refcount: &'info AtomicUsize,
|
||||
_misc: &'info AtomicUsize,
|
||||
}
|
||||
struct PageInfoFree<'info> {
|
||||
prev: &'info AtomicUsize,
|
||||
next: &'info AtomicUsize,
|
||||
@@ -767,27 +759,19 @@ pub enum AddRefError {
|
||||
RcOverflow,
|
||||
}
|
||||
impl PageInfo {
|
||||
fn kind(&self) -> PageInfoKind<'_> {
|
||||
let prev = self.refcount.load(Ordering::Relaxed);
|
||||
fn as_free(&self) -> Option<PageInfoFree<'_>> {
|
||||
let this = &self;
|
||||
let prev = this.refcount.load(Ordering::Relaxed);
|
||||
|
||||
if prev & RC_USED_NOT_FREE == RC_USED_NOT_FREE {
|
||||
PageInfoKind::Used(PageInfoUsed {
|
||||
_refcount: &self.refcount,
|
||||
_misc: &self.next,
|
||||
})
|
||||
None
|
||||
} else {
|
||||
PageInfoKind::Free(PageInfoFree {
|
||||
prev: &self.refcount,
|
||||
next: &self.next,
|
||||
Some(PageInfoFree {
|
||||
prev: &this.refcount,
|
||||
next: &this.next,
|
||||
})
|
||||
}
|
||||
}
|
||||
fn as_free(&self) -> Option<PageInfoFree<'_>> {
|
||||
match self.kind() {
|
||||
PageInfoKind::Free(f) => Some(f),
|
||||
PageInfoKind::Used(_) => None,
|
||||
}
|
||||
}
|
||||
pub fn add_ref(&self, kind: RefKind) -> Result<(), AddRefError> {
|
||||
match (self.refcount().expect("cannot add_ref to free frame"), kind) {
|
||||
(RefCount::One, RefKind::Cow) => {
|
||||
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
// This code was adapted from MIT licensed https://github.com/antialize/ordered-locks
|
||||
// We cannot use that library directly as it is wrapping std::sync types
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
//! This create implement compiletime ordering of locks into levels, [`L1`], [`L2`], [`L3`], [`L4`] and [`L5`].
|
||||
//! In order to acquire a lock at level `i` only locks at level `i-1` or below may be held.
|
||||
//!
|
||||
@@ -17,7 +19,7 @@
|
||||
//! let v2 = Mutex::<L2, _>::new(43);
|
||||
//! // Construct a token indicating that this thread does not hold any locks
|
||||
//! let mut token = unsafe {CleanLockToken::new()};
|
||||
//!
|
||||
//!
|
||||
//! {
|
||||
//! // We can aquire the locks for v1 and v2 at the same time
|
||||
//! let mut g1 = v1.lock(token.token());
|
||||
@@ -41,7 +43,7 @@
|
||||
//! // Construct a token indicating that this thread does not hold any locks
|
||||
//! let mut clean_token = unsafe {CleanLockToken::new()};
|
||||
//! let token = clean_token.token();
|
||||
//!
|
||||
//!
|
||||
//! // Try to aquire locks in the wrong order
|
||||
//! let mut g2 = v2.lock(token);
|
||||
//! let (g2, token) = g2.token_split();
|
||||
|
||||
Reference in New Issue
Block a user