Skip to content

Commit

Permalink
Add 'Sync' to TaskType
Browse files Browse the repository at this point in the history
  • Loading branch information
try-box committed Dec 3, 2023
1 parent 273d4e5 commit bd92c1d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion task-exec-queue/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "task-exec-queue"
version = "0.8.1"
version = "0.9.0"
authors = ["try <trywen@qq.com>"]
edition = "2018"
description = "A asynchronous task execution queue"
Expand Down
6 changes: 3 additions & 3 deletions task-exec-queue/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait SpawnExt: futures::Future {
#[inline]
fn spawn<Tx, G>(self, queue: &TaskExecQueue<Tx, G>) -> Spawner<Self, Tx, G, ()>
where
Self: Sized + Send + 'static,
Self: Sized + Send + Sync + 'static,
Self::Output: Send + 'static,
Tx: Clone + Unpin + futures::Sink<((), TaskType)> + Send + Sync + 'static,
G: Hash + Eq + Clone + Debug + Send + Sync + 'static,
Expand All @@ -26,7 +26,7 @@ pub trait SpawnExt: futures::Future {
name: D,
) -> Spawner<Self, Tx, G, D>
where
Self: Sized + Send + 'static,
Self: Sized + Send + Sync + 'static,
Self::Output: Send + 'static,
Tx: Clone + Unpin + futures::Sink<(D, TaskType)> + Send + Sync + 'static,
G: Hash + Eq + Clone + Debug + Send + Sync + 'static,
Expand All @@ -42,7 +42,7 @@ pub trait SpawnDefaultExt: futures::Future {
#[inline]
fn spawn(self) -> Spawner<'static, Self, futures::channel::mpsc::Sender<((), TaskType)>, (), ()>
where
Self: Sized + Send + 'static,
Self: Sized + Send + Sync + 'static,
Self::Output: Send + 'static,
{
let f = Spawner::new(default(), self, ());
Expand Down
10 changes: 5 additions & 5 deletions task-exec-queue/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use super::{
type DashMap<K, V> = dashmap::DashMap<K, V, ahash::RandomState>;
type GroupChannels<G> = Arc<DashMap<G, Arc<Mutex<GroupTaskExecQueue<TaskType>>>>>;

pub type TaskType = Box<dyn std::future::Future<Output = ()> + Send + 'static + Unpin>;
pub type TaskType = Box<dyn std::future::Future<Output = ()> + Send + Sync + 'static + Unpin>;

pub struct TaskExecQueue<Tx = mpsc::Sender<((), TaskType)>, G = (), D = ()> {
pub(crate) tx: Tx,
Expand Down Expand Up @@ -109,7 +109,7 @@ where
pub fn try_spawn_with<T>(&self, msg: T, name: D) -> TrySpawner<'_, T, Tx, G, D>
where
D: Clone,
T: Future + Send + 'static,
T: Future + Send + Sync + 'static,
T::Output: Send + 'static,
{
let fut = TrySpawner::new(self, msg, name);
Expand All @@ -120,7 +120,7 @@ where
pub fn spawn_with<T>(&self, msg: T, name: D) -> Spawner<'_, T, Tx, G, D>
where
D: Clone,
T: Future + Send + 'static,
T: Future + Send + Sync + 'static,
T::Output: Send + 'static,
{
let fut = Spawner::new(self, msg, name);
Expand Down Expand Up @@ -297,7 +297,7 @@ where
#[inline]
pub fn try_spawn<T>(&self, task: T) -> TrySpawner<'_, T, Tx, G, ()>
where
T: Future + Send + 'static,
T: Future + Send + Sync + 'static,
T::Output: Send + 'static,
{
let fut = TrySpawner::new(self, task, ());
Expand All @@ -307,7 +307,7 @@ where
#[inline]
pub fn spawn<T>(&self, task: T) -> Spawner<'_, T, Tx, G, ()>
where
T: Future + Send + 'static,
T: Future + Send + Sync + 'static,
T::Output: Send + 'static,
{
let fut = Spawner::new(self, task, ());
Expand Down
20 changes: 10 additions & 10 deletions task-exec-queue/src/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
#[inline]
pub async fn result(mut self) -> Result<Item::Output, Error<Item>>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
{
if self.inner.sink.is_closed() {
Expand Down Expand Up @@ -106,7 +106,7 @@ where

impl<Item, Tx, G> Future for GroupSpawner<'_, Item, Tx, G>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
Tx: Clone + Unpin + Sink<((), TaskType)> + Send + Sync + 'static,
G: Hash + Eq + Clone + Debug + Send + Sync + 'static,
Expand Down Expand Up @@ -195,7 +195,7 @@ where
#[inline]
pub async fn result(mut self) -> Result<Item::Output, Error<Item>>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
{
if self.inner.inner.sink.is_full() {
Expand All @@ -209,7 +209,7 @@ where

impl<Item, Tx, G> Future for TryGroupSpawner<'_, Item, Tx, G>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
Tx: Clone + Unpin + Sink<((), TaskType)> + Send + Sync + 'static,
G: Hash + Eq + Clone + Debug + Send + Sync + 'static,
Expand Down Expand Up @@ -247,7 +247,7 @@ where
#[inline]
pub fn group(self, name: G) -> GroupSpawner<'a, Item, Tx, G>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
{
let fut = GroupSpawner::new(self, name);
Expand Down Expand Up @@ -280,7 +280,7 @@ where
#[inline]
pub async fn result(mut self) -> Result<Item::Output, Error<Item>>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
{
if self.sink.is_closed() {
Expand Down Expand Up @@ -337,7 +337,7 @@ where

impl<Item, Tx, G, D> Future for Spawner<'_, Item, Tx, G, D>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
Tx: Clone + Unpin + Sink<(D, TaskType)> + Send + Sync + 'static,
G: Hash + Eq + Clone + Debug + Send + Sync + 'static,
Expand Down Expand Up @@ -412,7 +412,7 @@ where
#[inline]
pub fn group(self, name: G) -> TryGroupSpawner<'a, Item, Tx, G>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
{
let fut = TryGroupSpawner::new(self.inner, name);
Expand Down Expand Up @@ -447,7 +447,7 @@ where
#[inline]
pub async fn result(mut self) -> Result<Item::Output, Error<Item>>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
{
if self.inner.sink.is_full() {
Expand All @@ -459,7 +459,7 @@ where

impl<Item, Tx, G, D> Future for TrySpawner<'_, Item, Tx, G, D>
where
Item: Future + Send + 'static,
Item: Future + Send + Sync + 'static,
Item::Output: Send + 'static,
Tx: Clone + Unpin + Sink<(D, TaskType)> + Send + Sync + 'static,
G: Hash + Eq + Clone + Debug + Send + Sync + 'static,
Expand Down

0 comments on commit bd92c1d

Please sign in to comment.