Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions vortex-io/src/runtime/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::task::Context;
use std::task::Poll;
use std::task::ready;

use futures::channel::oneshot::channel;
use futures::channel::oneshot::Receiver;
use futures::FutureExt;
use tracing::Instrument;
use vortex_error::vortex_panic;
Expand Down Expand Up @@ -65,7 +67,7 @@ impl Handle {
Fut: Future<Output = R> + Send + 'static,
R: Send + 'static,
{
let (send, recv) = oneshot::channel();
let (send, recv) = channel();
let span = tracing::Span::current();
let abort_handle = self.runtime().spawn(
async move {
Expand Down Expand Up @@ -105,12 +107,12 @@ impl Handle {
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
let (send, recv) = oneshot::channel();
let (send, recv) = channel();
let span = tracing::Span::current();
let abort_handle = self.runtime().spawn_cpu(Box::new(move || {
let _guard = span.enter();
// Optimistically avoid the work if the result won't be used.
if !send.is_closed() {
if !send.is_canceled() {
// Task::detach allows the receiver to be dropped, so we ignore send errors.
drop(send.send(f()));
}
Expand All @@ -127,12 +129,12 @@ impl Handle {
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
let (send, recv) = oneshot::channel();
let (send, recv) = channel();
let span = tracing::Span::current();
let abort_handle = self.runtime().spawn_blocking_io(Box::new(move || {
let _guard = span.enter();
// Optimistically avoid the work if the result won't be used.
if !send.is_closed() {
if !send.is_canceled() {
// Task::detach allows the receiver to be dropped, so we ignore send errors.
drop(send.send(f()));
}
Expand All @@ -150,7 +152,7 @@ impl Handle {
/// continue running in the background, call [`Task::detach`].
#[must_use = "When a Task is dropped without being awaited, it is cancelled"]
pub struct Task<T> {
recv: oneshot::AsyncReceiver<T>,
recv: Receiver<T>,
abort_handle: Option<AbortHandleRef>,
}

Expand Down
Loading