Skip to content

Commit a6199ae

Browse files
committed
remove unprotected guards
1 parent e8ed933 commit a6199ae

File tree

2 files changed

+1
-63
lines changed

2 files changed

+1
-63
lines changed

src/guard.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -333,65 +333,3 @@ impl Drop for OwnedGuard<'_> {
333333
unsafe { Thread::free(self.thread.id) };
334334
}
335335
}
336-
337-
/// Returns a dummy guard object.
338-
///
339-
/// Calling [`protect`](Guard::protect) on an unprotected guard will
340-
/// load the pointer directly, and [`retire`](Guard::defer_retire) will
341-
/// reclaim objects immediately.
342-
///
343-
/// Unprotected guards are useful when calling guarded functions
344-
/// on a data structure that has just been created or is about
345-
/// to be destroyed, because you know that no other thread holds
346-
/// a reference to it.
347-
///
348-
/// # Safety
349-
///
350-
/// You must ensure that code used with this guard is sound with
351-
/// the unprotected behavior described above.
352-
#[inline]
353-
pub unsafe fn unprotected() -> UnprotectedGuard {
354-
UnprotectedGuard
355-
}
356-
357-
/// A dummy guard object.
358-
///
359-
/// See [`unprotected`] for details.
360-
#[derive(Clone, Debug)]
361-
#[non_exhaustive]
362-
pub struct UnprotectedGuard;
363-
364-
impl Guard for UnprotectedGuard {
365-
/// Loads the pointer directly, using the given ordering.
366-
#[inline]
367-
fn protect<T>(&self, ptr: &AtomicPtr<T>, ordering: Ordering) -> *mut T {
368-
ptr.load(ordering)
369-
}
370-
371-
/// Reclaims the pointer immediately.
372-
#[inline]
373-
unsafe fn defer_retire<T>(&self, ptr: *mut T, reclaim: unsafe fn(*mut T)) {
374-
unsafe { reclaim(ptr) }
375-
}
376-
377-
/// This method is a no-op.
378-
#[inline]
379-
fn refresh(&mut self) {}
380-
381-
/// This method is a no-op.
382-
#[inline]
383-
fn flush(&self) {}
384-
385-
/// Returns a numeric identifier for the current thread.
386-
#[inline]
387-
fn thread_id(&self) -> usize {
388-
Thread::current().id
389-
}
390-
391-
/// Unprotected guards aren't tied to a specific collector, so this always
392-
/// returns `true`.
393-
#[inline]
394-
fn belongs_to(&self, _collector: &Collector) -> bool {
395-
true
396-
}
397-
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ pub mod guide;
1313
pub mod reclaim;
1414

1515
pub use collector::Collector;
16-
pub use guard::{unprotected, Guard, LocalGuard, OwnedGuard, UnprotectedGuard};
16+
pub use guard::{Guard, LocalGuard, OwnedGuard};

0 commit comments

Comments
 (0)