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