Diffstat (limited to 'src/effect/blocking.rs')
-rw-r--r--src/effect/blocking.rs82
1 files changed, 37 insertions, 45 deletions
diff --git a/src/effect/blocking.rs b/src/effect/blocking.rs
index 661fd12..5913dda 100644
--- a/src/effect/blocking.rs
+++ b/src/effect/blocking.rs
@@ -13,43 +13,49 @@ pub trait BlockOn: 'static {
<F as core::future::Future>::Output: Send;
}
-pub struct Blocking<B>(Marker<B>);
+pub struct Blocking<B = Spin>(Marker<B>);
#[repr(transparent)]
pub struct Value<T, B>(pub T, Marker<B>);
-impl<'lt, T: Send + Sync, B: BlockOn, O> ErasedForLt<'lt, T, Blocking<B>, &'lt (T, O), O> for Value<T, B> {
+impl<T, B> Value<T, B> {
+ pub fn value(self) -> T {
+ self.0
+ }
+}
+
+impl<'lt, T: Ss, B: BlockOn, O> ErasedForLt<'lt, T, Blocking<B>, &'lt (T, O), O> for Value<T, B> {
type T = Value<T, B>;
}
-impl<T: Send + Sync, B: BlockOn> ErasedHrt<T, Blocking<B>> for Value<T, B> {
+impl<T: Ss, B: BlockOn> ErasedHrt<T, Blocking<B>> for Value<T, B> {
type T<O> = Self;
}
impl<B: BlockOn> Effect for Blocking<B> {
- type Erased<T: Send + Sync> = Value<T, B>;
+ type Erased<T: Ss> = Value<T, B>;
- type Ready<'a, T: Send + Sync + 'a> = Value<T, B>;
+ type Ready<'a, T: Ss + 'a> = Value<T, B>;
- fn ready<'a, T: Send + Sync + 'a>(value: T) -> Self::Ready<'a, T> {
+ fn ready<'a, T: Ss + 'a>(value: T) -> Self::Ready<'a, T> {
Value(value, Default::default())
}
- type FromFuture<'a, F: Send + Sync + 'a> = Value<F::Output, B>
+ type FromFuture<'a, F: Ss + 'a> = Value<F::Output, B>
where
F: Future,
- F::Output: Send + Sync + 'a;
+ F::Output: Ss + 'a;
- fn from_future<'a, F: Send + Sync + 'a>(future: F) -> Self::FromFuture<'a, F>
+ fn from_future<'a, F: Ss + 'a>(future: F) -> Self::FromFuture<'a, F>
where
F: Future,
- F::Output: Send + Sync + 'a,
+ F::Output: Ss + 'a,
{
Value(B::block_on(future), Default::default())
}
}
-impl<'lt, U: Send + Sync + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
+impl<'lt, U: Ss + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
fn into_erased<X>(self) -> ErasedEffective<'lt, Self::Output, Self::Effect, X> {
self
}
@@ -64,13 +70,13 @@ impl<'lt, U: Send + Sync + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
core::future::ready(self.0)
}
- type Loop<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a>
+ type Loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>
= Value<(U, T), B>
where
F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect>,
'lt: 'a;
- fn r#loop<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a>(self, mut cb: F) -> Self::Loop<'ctx, 'a, T, F>
+ fn r#loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, mut cb: F) -> Self::Loop<'ctx, 'a, T, F>
where
F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect>,
'lt: 'a,
@@ -84,12 +90,12 @@ impl<'lt, U: Send + Sync + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
}
}
- type Map<'a, T: Send + Sync + 'a, F: Send + Sync + 'a> = Value<T, B>
+ type Map<'a, T: Ss + 'a, F: Ss + 'a> = Value<T, B>
where
F: FnOnce(Self::Output) -> T,
'lt: 'a;
- fn map<'a, T: Send + Sync + 'a, F: Send + Sync + 'a>(self, cb: F) -> Self::Map<'a, T, F>
+ fn map<'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Map<'a, T, F>
where
F: FnOnce(Self::Output) -> T,
'lt: 'a,
@@ -97,16 +103,13 @@ impl<'lt, U: Send + Sync + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
Value(cb(self.0), Default::default())
}
- type Then<'a, T: Send + Sync + 'a, V: Send + Sync + 'a, F: Send + Sync + 'a> = Value<T, B>
+ type Then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a> = Value<T, B>
where
F: FnOnce(Self::Output) -> V,
V: Effective<'a, Output = T, Effect = Self::Effect>,
'lt: 'a;
- fn then<'a, T: Send + Sync + 'a, V: Send + Sync + 'a, F: Send + Sync + 'a>(
- self,
- cb: F,
- ) -> Self::Then<'a, T, V, F>
+ fn then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Then<'a, T, V, F>
where
F: FnOnce(Self::Output) -> V,
V: Effective<'a, Output = T, Effect = Self::Effect>,
@@ -115,14 +118,17 @@ impl<'lt, U: Send + Sync + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
cb(self.0).into_erased::<()>()
}
- type AsCtx<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a> = Value<(U, T), B>
+ type AsCtx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a> = Value<(U, T), B>
where
F: for<'b> FnOnce(&'b mut Self::Output) -> ErasedEffective<'b, T, Self::Effect, (&'b mut Self::Output, &'ctx ())>,
'lt: 'a;
- fn as_ctx<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a>(self, cb: F) -> Self::AsCtx<'ctx, 'a, T, F>
+ fn as_ctx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::AsCtx<'ctx, 'a, T, F>
where
- F: for<'b> FnOnce(&'b mut Self::Output) -> ErasedEffective<'b, T, Self::Effect, (&'b mut Self::Output, &'ctx ())>,
+ F: for<'b> FnOnce(
+ &'b mut Self::Output,
+ )
+ -> ErasedEffective<'b, T, Self::Effect, (&'b mut Self::Output, &'ctx ())>,
'lt: 'a,
{
let mut this = self.0;
@@ -134,18 +140,18 @@ impl<'lt, U: Send + Sync + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
impl<B: BlockOn> Join for Blocking<B> {
type Effect = Blocking<B>;
- type Two<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a> = Value<(T0::Output, T1::Output), B>
+ type Two<'a, T0: Ss + 'a, T1: Ss + 'a> = Value<(T0::Output, T1::Output), B>
where
T0: Effective<'a, Effect = Self::Effect>,
T1: Effective<'a, Effect = Self::Effect>;
- type Three<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a, T2: Send + Sync + 'a> = Value<(T0::Output, T1::Output, T2::Output), B>
+ type Three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a> = Value<(T0::Output, T1::Output, T2::Output), B>
where
T0: Effective<'a, Effect = Self::Effect>,
T1: Effective<'a, Effect = Self::Effect>,
T2: Effective<'a, Effect = Self::Effect>;
- fn two<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a>(cb: (T0, T1)) -> Self::Two<'a, T0, T1>
+ fn two<'a, T0: Ss + 'a, T1: Ss + 'a>(cb: (T0, T1)) -> Self::Two<'a, T0, T1>
where
T0: Effective<'a, Effect = Self::Effect>,
T1: Effective<'a, Effect = Self::Effect>,
@@ -156,7 +162,7 @@ impl<B: BlockOn> Join for Blocking<B> {
Value((v0, v1), Default::default())
}
- fn three<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a, T2: Send + Sync + 'a>(
+ fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a>(
cb: (T0, T1, T2),
) -> Self::Three<'a, T0, T1, T2>
where
@@ -175,24 +181,18 @@ impl<B: BlockOn> Join for Blocking<B> {
impl<B: BlockOn> TryJoin for Blocking<B> {
type Effect = Blocking<B>;
- type Two<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a> = Value<Result<(T0::Ok, T1::Ok), T0::Err>, B>
+ type Two<'a, T0: Ss + 'a, T1: Ss + 'a> = Value<Result<(T0::Ok, T1::Ok), T0::Err>, B>
where
T0: TryEffective<'a, Effect = Self::Effect>,
T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>;
- type Three<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a, T2: Send + Sync + 'a> = Value<Result<(T0::Ok, T1::Ok, T2::Ok), T0::Err>, B>
+ type Three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a> = Value<Result<(T0::Ok, T1::Ok, T2::Ok), T0::Err>, B>
where
T0: TryEffective<'a, Effect = Self::Effect>,
T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>,
T2: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>;
- fn two<
- 'a,
- T0: Send + Sync + 'a,
- T1: Send + Sync + 'a,
- F0: Send + Sync + 'a,
- F1: Send + Sync + 'a,
- >(
+ fn two<'a, T0: Ss + 'a, T1: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a>(
cb: (F0, F1),
) -> Self::Two<'a, T0, T1>
where
@@ -214,15 +214,7 @@ impl<B: BlockOn> TryJoin for Blocking<B> {
Value(Ok((v0, v1)), Default::default())
}
- fn three<
- 'a,
- T0: Send + Sync + 'a,
- T1: Send + Sync + 'a,
- T2: Send + Sync + 'a,
- F0: Send + Sync + 'a,
- F1: Send + Sync + 'a,
- F2: Send + Sync + 'a,
- >(
+ fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a, F2: Ss + 'a>(
cb: (F0, F1, F2),
) -> Self::Three<'a, T0, T1, T2>
where