Crates.io | permit |
lib.rs | permit |
version | 0.2.1 |
source | src |
created_at | 2021-03-25 00:57:13.143853 |
updated_at | 2023-04-16 16:03:48.352363 |
description | A struct for cancelling operations. |
homepage | |
repository | https://gitlab.com/leonhard-llc/ops |
max_upload_size | |
id | 373163 |
size | 29,490 |
permit::Permit
is a struct for cancelling operations.
Future
. You can await
a permit and return when it is revoked.context
std
.forbid(unsafe_code)
alloc::sync::Arc
.async_ctx
stopper
io-context
ctx
Graceful shutdown:
let top_permit = permit::Permit::new();
// Start some worker threads.
for _ in 0..5 {
let permit = top_permit.new_sub();
std::thread::spawn(move || {
while !permit.is_revoked() {
// ...
}
});
}
wait_for_shutdown_signal();
// Revoke all thread permits and wait for them to
// finish and drop their permits.
top_permit
.revoke()
.wait_subs_timeout(Duration::from_secs(3))
.unwrap();
Metric output format: x/y
x = unsafe code used by the build
y = total unsafe code found in the crate
Symbols:
🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)]
❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)]
☢️ = `unsafe` usage found
Functions Expressions Impls Traits Methods Dependency
0/0 0/0 0/0 0/0 0/0 🔒 permit 0.2.1
0/0 0/0 0/0 0/0 0/0
sleep
and sleep_until
would sometimes not return early.try_wait_for
to wait_subs_timeout
try_wait_until
to wait_subs_deadline
wait*
methodswait
sleep
and sleep_until
Debug
revoke()
and then wait()
would not wait.std::task::Waker
structs.Future
revoke
return &Self
License: Apache-2.0