diff --git a/elfo-core/src/envelope.rs b/elfo-core/src/envelope.rs index 6c99b2a1..f3b40b25 100644 --- a/elfo-core/src/envelope.rs +++ b/elfo-core/src/envelope.rs @@ -21,7 +21,7 @@ use crate::{ /// /// [`Context`]: crate::Context /// [`msg!`]: crate::msg -pub struct Envelope(NonNull); // TODO: Pin>? +pub struct Envelope(NonNull); // Messages aren't required to be `Sync`. assert_not_impl_any!(Envelope: Sync); diff --git a/elfo-core/src/mailbox.rs b/elfo-core/src/mailbox.rs index 1417a54c..c6cdf4c0 100644 --- a/elfo-core/src/mailbox.rs +++ b/elfo-core/src/mailbox.rs @@ -49,9 +49,12 @@ assert_not_impl_any!(EnvelopeHeader: Unpin); // SAFETY: // * `EnvelopeHeader` is pinned in memory while it is in the queue, the only way // to access inserted `EnvelopeHeader` is by using the `dequeue()` method. -// * `EnvelopeHeader` cannot be deallocated without prunning the queue. -// * `EnvelopeHeader` doesn't implement `Unpin` (checked statically). -unsafe impl Linked> for EnvelopeHeader { +// * `EnvelopeHeader` cannot be deallocated without prunning the queue, which is +// done also by calling `dequeue()` method multiple times. +// * `EnvelopeHeader` doesn't implement `Unpin` (checked statically above). +unsafe impl Linked for EnvelopeHeader { + // It would be nice to enforce pinning here by using `Pin`. + // However, it's not possible because `Pin` requires `Deref` impl. type Handle = Envelope; fn into_ptr(handle: Self::Handle) -> NonNull { @@ -62,7 +65,7 @@ unsafe impl Linked> for EnvelopeHeader { Self::Handle::from_header_ptr(ptr) } - unsafe fn links(ptr: NonNull) -> NonNull> { + unsafe fn links(ptr: NonNull) -> NonNull { // Using `ptr::addr_of_mut!` permits us to avoid creating a temporary // reference without using layout-dependent casts. let links = ptr::addr_of_mut!((*ptr.as_ptr()).link); diff --git a/elfo-core/src/message/any.rs b/elfo-core/src/message/any.rs index 5087f2e2..6e3a240c 100644 --- a/elfo-core/src/message/any.rs +++ b/elfo-core/src/message/any.rs @@ -38,8 +38,6 @@ assert_not_impl_any!(AnyMessage: Sync); // SAFETY: `AnyMessage` can point to `M: Message` only, which is `Send`. unsafe impl Send for AnyMessage {} -// TODO: Pin/Unpin? - impl AnyMessage { /// Converts a message into [`AnyMessage`]. #[inline]