-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
I wanted to have a linked list of Arc<dyn DynTask> for a toy async runtime I am working on. It took a bit of effort but I did eventually manage to define an adaptor that works. I thought I would share it here for lack of any other suitable discussion place.
The basis of this impl is the FatLink, which is a linked list link + a type-erased get_value function that the Adapter impl uses.
pub(crate) struct FatLink<D: ?Sized> {
link: XorLinkedListAtomicLink,
get_value: unsafe fn(link: NonNull<FatLink<D>>) -> *const D,
}Unfortunately, I needed to add this get_link method to the DynTask trait, which requires feature(arbitrary_self_types). I could not figure out a way to avoid the nightly dep here.
unsafe fn get_link(self: *const Self) -> NonNull<FatLink<dyn DynTask>> {
<Self as FatLinked<dyn DynTask>>::get_link(self)
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels