Crates.io | async-gate |
lib.rs | async-gate |
version | 0.3.1 |
source | src |
created_at | 2023-09-01 20:34:14.722102 |
updated_at | 2024-02-28 19:16:47.148682 |
description | A Tokio-powered asynchronous gate (analogous to a flag and highly inspired by Python's `asyncio.Event`, but can be waited for to become 'false' too) |
homepage | |
repository | https://github.com/babichjacob/async-gate |
max_upload_size | |
id | 961164 |
size | 31,161 |
This Rust library is an asynchronous "gate" that can be waited to be raised or lowered, as controlled by a corresponding "lever".
This crate is published to crates.io as async-gate
, so you can do
cargo add async-gate
to add it to your project's dependencies.
You probably don't want to use this if you aren't me; the code is clunky and only moderately documented and tested. You might benefit more from using a plain tokio::sync::watch
channel with your own layer of logic on top.
Create an issue and I'll try to help.
Create an issue or pull request and I'll try to fix.
Licensed under either of:
at your option.
This implementation is heavily borrowed from @EFanZh's contributions in this Rust forum post.
The idea is highly inspired by Python's asyncio.Event
, but a gate can be waited for to become 'clear' too (not just 'set').
This library is implemented with Tokio
's watch
channel.
I also developed awaitable-bool
right after making async-gate
. That unifies changing the value of the bool and waiting for value changes into a single type (AwaitableBool
). It is simpler than this crate.
This README was generated with ❤️ by readme-md-generator