Skip to content

Add blocking wrapper #16

@zeenix

Description

@zeenix

Suggesting we add a blocking::Task, a thin blocking wrapper of Task that's more convenient to use in the blocking code. API:

pub mod blocking {
    pub struct Task<T>(crate::Task<T>);

    impl<T> Task<T> {
        fn cancel(self);
        fn detach(self) -> Option<T>;
        fn wait(self) -> T;
    }

    impl<T> Deref for Task<T> {
        type Target = crate::Task<T>;
        ...
    }

    impl From<crate::Task<T>> for Task<T>;
    impl From<Task<T>> for crate::Task<T>;
}

For the implementation, we will either want to depend on pollster for its block_on or async-io, which IMO would be a bit of an overkill so if we go for async-io, we probably want to feature gate this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions