Split async-std support and refactor
This commit is contained in:
parent
cb7b6446de
commit
ba59933810
|
@ -12,7 +12,8 @@ arbitrary = [ ]
|
|||
|
||||
std = [ ]
|
||||
|
||||
async-std = [ "dep:async-std", "async-std/alloc", "async-std/default" ]
|
||||
async-std = [ "dep:async-std" ]
|
||||
async-std-task = [ "async-std", "async-std/alloc", "async-std/default" ]
|
||||
tokio1 = [ "dep:tokio1" ]
|
||||
tokio1-sync = [ "tokio1", "tokio1/sync" ]
|
||||
tokio1-task = [ "tokio1", "tokio1/rt" ]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#[cfg(feature = "async-std-task")]
|
||||
mod impl_task {
|
||||
use async_std::task::JoinHandle;
|
||||
|
||||
use crate::{DropGuard, DropGuarded};
|
||||
|
@ -20,3 +22,4 @@ impl<T> core::future::Future for DropGuard<JoinHandle<T>> {
|
|||
core::pin::Pin::new(handle).poll(cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::DropGuarded;
|
||||
|
||||
#[cfg(feature = "tokio1-task")]
|
||||
mod impl_task {
|
||||
use crate::{DropGuard, DropGuarded};
|
||||
|
@ -28,17 +26,20 @@ mod impl_task {
|
|||
}
|
||||
|
||||
#[cfg(feature = "tokio1-sync")]
|
||||
mod impl_sync {
|
||||
use crate::DropGuarded;
|
||||
|
||||
impl DropGuarded for tokio1::sync::oneshot::Sender<()> {
|
||||
#[inline]
|
||||
fn cancel(self) {
|
||||
let _ = self.send(());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "tokio1-sync", feature = "std"))]
|
||||
#[cfg(feature = "std")]
|
||||
impl DropGuarded for std::sync::Arc<tokio1::sync::Semaphore> {
|
||||
#[inline]
|
||||
fn cancel(self) {
|
||||
self.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue