Skip to content

Commit

Permalink
Merge #883 #884
Browse files Browse the repository at this point in the history
883: channel: Attempt to fix flaky doctest r=taiki-e a=taiki-e

https://github.com/crossbeam-rs/crossbeam/runs/7479566226?check_suite_focus=true

884: epoch: Seal Pointer trait r=taiki-e a=taiki-e

Closes #620

Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
bors[bot] and taiki-e authored Jul 23, 2022
3 parents 568f558 + da959c9 + 1d22218 commit a83cb9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crossbeam-channel/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
/// let ms = |ms| Duration::from_millis(ms);
///
/// // Returns `true` if `a` and `b` are very close `Instant`s.
/// let eq = |a, b| a + ms(50) > b && b + ms(50) > a;
/// let eq = |a, b| a + ms(60) > b && b + ms(60) > a;
///
/// let start = Instant::now();
/// let r = after(ms(100));
Expand Down
7 changes: 5 additions & 2 deletions crossbeam-epoch/src/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,9 @@ impl<T> From<*const T> for Atomic<T> {
}

/// A trait for either `Owned` or `Shared` pointers.
// TODO: seal this trait https://github.com/crossbeam-rs/crossbeam/issues/620
pub trait Pointer<T: ?Sized + Pointable> {
///
/// This trait is sealed and cannot be implemented for types outside of `crossbeam-epoch`.
pub trait Pointer<T: ?Sized + Pointable>: crate::sealed::Sealed {
/// Returns the machine representation of the pointer.
fn into_ptr(self) -> *mut ();

Expand All @@ -916,6 +917,7 @@ pub struct Owned<T: ?Sized + Pointable> {
_marker: PhantomData<Box<T>>,
}

impl<T: ?Sized + Pointable> crate::sealed::Sealed for Owned<T> {}
impl<T: ?Sized + Pointable> Pointer<T> for Owned<T> {
#[inline]
fn into_ptr(self) -> *mut () {
Expand Down Expand Up @@ -1176,6 +1178,7 @@ impl<T: ?Sized + Pointable> Clone for Shared<'_, T> {

impl<T: ?Sized + Pointable> Copy for Shared<'_, T> {}

impl<T: ?Sized + Pointable> crate::sealed::Sealed for Shared<'_, T> {}
impl<T: ?Sized + Pointable> Pointer<T> for Shared<'_, T> {
#[inline]
fn into_ptr(self) -> *mut () {
Expand Down
4 changes: 4 additions & 0 deletions crossbeam-epoch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ cfg_if! {
};
pub use self::collector::{Collector, LocalHandle};
pub use self::guard::{unprotected, Guard};

mod sealed {
pub trait Sealed {}
}
}
}

Expand Down

0 comments on commit a83cb9d

Please sign in to comment.