Cleanup#1457
Conversation
| } | ||
| }; | ||
| } | ||
| #[inline] |
There was a problem hiding this comment.
I doubt this has any effect, since the method is always virtually dispatched.
| // Forget the Arcs again, so that the refcount isn't decrased | ||
| let _ = Arc::into_raw(arc); | ||
| let _ = Arc::into_raw(arc_clone); | ||
| mem::forget(arc); |
There was a problem hiding this comment.
I used Arc::into_raw since that's the version where the API guarantees that it's the opposite of Arc::from_raw.
forget will work too, but I thought if there is a more specific API available it might be nice to use it.
Anyway, both is fine.
|
|
||
| unsafe fn clone_arc_raw<T: ArcWake>(data: *const()) -> RawWaker { | ||
| // used by `waker_ref` | ||
| pub(super) unsafe fn clone_arc_raw<T: ArcWake>(data: *const()) -> RawWaker { |
There was a problem hiding this comment.
Where are those things exported to now? Only one level above, or even further?
It's totally to fine to use those within other parts of futures-util, but I don't think the library should publicly export these.
There was a problem hiding this comment.
They're just pub(super)-- so only available to the futures_util::task module.
| // Lazily create the `Arc` only when the waker is actually cloned. | ||
| // FIXME: remove `transmute` when a `Waker` -> `RawWaker` conversion | ||
| // function is landed in `core`. | ||
| mem::transmute::<task03::Waker, RawWaker>( |
There was a problem hiding this comment.
A method on ArcWake or the same module that returns a RawWaker seems cleaner than transmute.
The ideal solution might be to directly reference and reuse a refcounted thing within Task01. But after looking up the definition of that I don't think it's possible without the extra allocation and wrapping.
Fixes some leftover bits from #1445