diff --git a/core/io/completions.rs b/core/io/completions.rs index 3b88bd6c8..3b44e29ff 100644 --- a/core/io/completions.rs +++ b/core/io/completions.rs @@ -11,10 +11,10 @@ use parking_lot::Mutex; use crate::{Buffer, CompletionError}; -pub type ReadComplete = dyn Fn(Result<(Arc, i32), CompletionError>) + Send; -pub type WriteComplete = dyn Fn(Result) + Send; -pub type SyncComplete = dyn Fn(Result) + Send; -pub type TruncateComplete = dyn Fn(Result) + Send; +pub type ReadComplete = dyn Fn(Result<(Arc, i32), CompletionError>) + Send + Sync; +pub type WriteComplete = dyn Fn(Result) + Send + Sync; +pub type SyncComplete = dyn Fn(Result) + Send + Sync; +pub type TruncateComplete = dyn Fn(Result) + Send + Sync; #[must_use] #[derive(Debug, Clone)] @@ -23,9 +23,6 @@ pub struct Completion { pub(super) inner: Option>, } -// Completion can be Sent between threads in case of async IO (like io_uring) when arbitrary thread -// can start to execute completion for CQE arrived from the kernel in the ring -unsafe impl Send for Completion {} #[derive(Debug, Default)] struct ContextInner { @@ -279,7 +276,7 @@ impl Completion { pub fn new_write_linked(complete: F) -> Self where - F: Fn(Result) + Send + 'static, + F: Fn(Result) + Send + Sync + 'static, { Self::new_linked(CompletionType::Write(WriteCompletion::new(Box::new( complete, @@ -288,7 +285,7 @@ impl Completion { pub fn new_write(complete: F) -> Self where - F: Fn(Result) + Send + 'static, + F: Fn(Result) + Send + Sync + 'static, { Self::new(CompletionType::Write(WriteCompletion::new(Box::new( complete, @@ -297,7 +294,7 @@ impl Completion { pub fn new_read(buf: Arc, complete: F) -> Self where - F: Fn(Result<(Arc, i32), CompletionError>) + Send + 'static, + F: Fn(Result<(Arc, i32), CompletionError>) + Send + Sync + 'static, { Self::new(CompletionType::Read(ReadCompletion::new( buf, @@ -306,7 +303,7 @@ impl Completion { } pub fn new_sync(complete: F) -> Self where - F: Fn(Result) + Send + 'static, + F: Fn(Result) + Send + Sync + 'static, { Self::new(CompletionType::Sync(SyncCompletion::new(Box::new( complete, @@ -315,7 +312,7 @@ impl Completion { pub fn new_trunc(complete: F) -> Self where - F: Fn(Result) + Send + 'static, + F: Fn(Result) + Send + Sync + 'static, { Self::new(CompletionType::Truncate(TruncateCompletion::new(Box::new( complete,