Wait for async tasks

Overview

Crates.io docs.rs Build

taskwait

Runtime agnostic way of waiting for async tasks.

Features

  • Done: Support for golang's WaitGroup.Add & WaitGroup.Done
  • Done: Support for RAII based done()ing the task i.e. calling done() on drop.
  • Done: Mixing of both add, done and RAII semantics.
  • Done: Reuse the same taskgroup for multiple checkpoints.

Example

Using add & done

use taskwait::TaskGroup;
 
let tg = TaskGroup::();
for _ in 0..10 {
    tg.add();
    let tg_c = tg.clone();
    tokio::spawn(async move{
        ...
        tg_c.done();
    })
}
tg.wait().await;

Using RAII with add_work

use taskwait::TaskGroup;
 
let tg = TaskGroup::();
for _ in 0..10 {
    let work = tg.add_work(1); // Increment counter
    tokio::spawn(async move{
        let _work = work; // done() will be called when this is dropped
        ...
    })
}
tg.wait().await;
You might also like...
A lock-free, partially wait-free, eventually consistent, concurrent hashmap.
A lock-free, partially wait-free, eventually consistent, concurrent hashmap.

A lock-free, partially wait-free, eventually consistent, concurrent hashmap. This map implementation allows reads to always be wait-free on certain pl

Cross-platform atomic wait and wake (aka futex) functionality for Rust.

Cross platform atomic wait and wake (aka futex) functionality. This crate only supports functionality that's available on all of Linux, Windows, and m

Rust library for concurrent data access, using memory-mapped files, zero-copy deserialization, and wait-free synchronization.

mmap-sync mmap-sync is a Rust crate designed to manage high-performance, concurrent data access between a single writer process and multiple reader pr

wait what? generate your entire infra from rust macros

infra as macro translate rust structs to terraform at compile time // your infra is a macro static DB: Postgres = Postgres16! { host: "env.host",

A rust library for sharing and updating arbitrary slices between threads, optimized for wait-free reads

atomicslice A Rust library for thread-safe shared slices that are just about as fast as possible to read while also being writable. Overview Use Atomi

Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async
Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async

CDRS CDRS is looking for maintainers CDRS is Apache Cassandra driver written in pure Rust. 💡 Looking for an async version? async-std https://github.c

📺 Netflix in Rust/ React-TS/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Kafka, Redis, Tokio, Actix, Elasticsearch, Influxdb Iox, Tensorflow, AWS
📺 Netflix in Rust/ React-TS/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Kafka, Redis, Tokio, Actix, Elasticsearch, Influxdb Iox, Tensorflow, AWS

Fullstack Movie Streaming Platform 📺 Netflix in RUST/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Spark, Kafka, Redis,

An feature packed Google Tasks CLI written purely in Rust
An feature packed Google Tasks CLI written purely in Rust

rChore A feature packed unofficial Google Tasks CLI to boost your producitvity, written purely in Rust. 🤔 What is rChore? rChore is an unofficial Goo

A lock-free thread-owned queue whereby tasks are taken by stealers in entirety via buffer swapping

Swap Queue A lock-free thread-owned queue whereby tasks are taken by stealers in entirety via buffer swapping. This is meant to be used [thread_local]

A thread pool for running multiple tasks on a configurable group of threads.
A thread pool for running multiple tasks on a configurable group of threads.

Threadfin A thread pool for running multiple tasks on a configurable group of threads. Extra features: Dynamic pool size based on load Support for asy

Comparing performance of Rust math libraries for common 3D game and graphics tasks

mathbench mathbench is a suite of unit tests and benchmarks comparing the output and performance of a number of different Rust linear algebra librarie

Create tasks and save notes offline from your terminal

Create tasks and save notes offline from your terminal

Slack bot for self-servicing automation of common or predictable tasks.
Slack bot for self-servicing automation of common or predictable tasks.

receptionist-bot-rs Slack bot for self-servicing automation of common or predictable tasks. Receptionist bot aims to provide a no-code frontend for te

An utility to help developers manage their emails, notes and tasks effectively

nitride An admin dashboard built on Vue.js, TypeScript, Rust, and PostgreSQL. See the User Interface source code here. Requirement Rust v1.63 or great

A modern high-performance open source file analysis library for automating localization tasks

🧛 Filecount Filecount is a modern high-performance open source file analysis library for automating localization tasks. It enables you to add file an

A library providing helpers for various StarkNet fees related tasks.
A library providing helpers for various StarkNet fees related tasks.

🐺 How Much ? 🦀 Table of Contents About Getting Started Prerequisites Installation Usage Estimate fees on network Authors & contributors Security Lic

My utils for long-lived, fault-tolerant rust tasks

Sisyphus Utilities for long-running, resilient tasks. This library contains code I wrote, found useful, and want to keep using. It aims to provide sys

Horus is an open source tool for running forensic and administrative tasks at the kernel level using eBPF, a low-overhead in-kernel virtual machine, and the Rust programming language.
Horus is an open source tool for running forensic and administrative tasks at the kernel level using eBPF, a low-overhead in-kernel virtual machine, and the Rust programming language.

Horus Horus is an open-source tool for running forensic and administrative tasks at the kernel level using eBPF, a low-overhead in-kernel virtual mach

A code generator to reduce repetitive tasks and build high-quality Rust libraries. 🦀

LibMake A code generator to reduce repetitive tasks and build high-quality Rust libraries Welcome to libmake 👋 Website • Documentation • Report Bug •

Comments
  • fix: register waker before loading/checking counter value to avoid a race condition that would result in lost notification

    fix: register waker before loading/checking counter value to avoid a race condition that would result in lost notification

    Although fetch_sub returns previous value, expression 'prev_val -n' evaluates to same value what ever is stored in counter after fetch_sub operation. So done_n is waking up the future twice (for 'prev_val - n' = 1 and 0) and hence causing notification miss sometimes.

    case: Suppose we have spawned 'x' number of tasks and gave one 'work' (tg.add_work(1)) to each. lets say 'x-2' are already dropped. Now consider done_n wakes up the future when prev_val - n == 1, so executor invokes the poll method, after loading the counter value and before registering the waker in poll, done_n again wakes up the future when prev_val -n == 0 causes the notification miss (waker was not registered yet), poll will continue the execution, register waker and return pending. tg.wait().await will go in indefinite waiting state.

    Note: registering waker in else block and keeping prev_val - n <= 0 in done_n method can cause same problem sometimes,very rare but could happen.

    opened by ab-basit 3
Owner
null
Wait Service is a pure rust program to test and wait on the availability of a service.

Wait Service Wait Service is a pure rust program to test and wait on the availability of a service.

Magic Len (Ron Li) 3 Jan 18, 2022
wait-for-pid -- Wait for processes to exit

wait-for-pid -- Wait for processes to exit wait-for-pid PID is similar to the bash built-in command wait, except it works even when the processes star

Tv 2 Feb 2, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.

delay-timer Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.

BinCheng 255 Dec 30, 2022
A Rust on-site channel benchmarking helper. Inter-Process (async / busy) & Intra-Process (async single threaded / async multi threaded)

On-Site Rust Channel Benchmarking Helper Deploy on server to determine which public crates are the fastest for communicating in different architecture

null 23 Jul 9, 2024
Wait, another virtual machine ?

WAVM WAVM, Wait, another virtual machine ?, is a register based 64 bits virtual machine written in Rust. It relies on 32 registers and 31 opcodes that

Wafelack 61 May 2, 2022
wait-free spsc linked-list queue with individually reusable nodes

A wait-free single-producer single-consumer linked-list queue with individually reusable nodes.

glowcoil 22 Dec 26, 2022
Tells you how many years you need to wait until your subatomic xeon crystal synchronizer has doubled in plasma inversion efficiency on the Goldberg-Moleman scale or whatever.

about Tells you how many years you need to wait until your subatomic xeon crystal synchronizer has doubled in plasma inversion efficiency on the Goldb

null 2 Dec 3, 2021
Tiny crate that allows to wait for a stop signal across multiple threads

Tiny crate that allows to wait for a stop signal across multiple threads. Helpful mostly in server applications that run indefinitely and need a signal for graceful shutdowns.

Dominik Nakamura 5 Dec 16, 2022
wait-free 4-level 64-bit pagetable for contiguous low-contention concurrent metadata

pagetable Wait-free 4-level page table that maps from a u64 key to an &AtomicU64 value. Page fan-out is 2^16. If a key doesn't exist, intermediate pag

Komora 21 Nov 20, 2022