Skip to content

Commit 76bf8d3

Browse files
committed
tweaks
1 parent ea977d1 commit 76bf8d3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

rust/core/src/sync.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::collections::HashSet;
2020
use arrow_array::{RecordBatch, RecordBatchReader};
2121
use arrow_schema::Schema;
2222

23-
use crate::error::Result;
23+
use crate::error::{Error, Result, Status};
2424
use crate::options::{self, OptionConnection, OptionDatabase, OptionStatement, OptionValue};
2525
use crate::PartitionedResult;
2626

@@ -44,12 +44,13 @@ pub trait Optionable {
4444
fn get_option_double(&self, key: Self::Option) -> Result<f64>;
4545
}
4646

47-
/// A handle to cancel an in-progress operation on a connection.
47+
/// A handle to cancel an in-progress operation.
4848
///
4949
/// This is a separated handle because otherwise it would be impossible to
50-
/// call a `cancel` method on a connection or statement itself.
51-
pub trait CancelHandle: Send {
52-
/// Cancel the in-progress operation on a connection.
50+
/// safely call a `cancel` method on a database/connection/statement itself
51+
/// due to the borrow checker.
52+
pub trait CancelHandle: Send + Sync {
53+
/// Attempt to cancel the in-progress operation (best-effort).
5354
fn try_cancel(&self) -> Result<()>;
5455
}
5556

@@ -58,7 +59,10 @@ pub struct NoOpCancellationHandle;
5859

5960
impl CancelHandle for NoOpCancellationHandle {
6061
fn try_cancel(&self) -> Result<()> {
61-
Ok(())
62+
Err(Error::with_message_and_status(
63+
"cancellation not implemented",
64+
Status::Unknown,
65+
))
6266
}
6367
}
6468

0 commit comments

Comments
 (0)