permit::Permit
is a struct for cancelling operations.
context
std
.forbid(unsafe_code)
alloc::sync::Arc
.async_ctx
io-context
ctx
Graceful shutdown:
rust
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 an drop their permits.
top_permit.revoke().try_wait_for(
core::time::Duration::from_secs(3));
```
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(unsafecode)]
❓ = No unsafe
usage found, missing #![forbid(unsafecode)]
☢️ = unsafe
usage found
Functions Expressions Impls Traits Methods Dependency
0/0 0/0 0/0 0/0 0/0 🔒 permit 0.1.1
0/0 0/0 0/0 0/0 0/0
```
revoke
return &Self
Fixing bugs and adding features is easy and fast. Send us a pull request and we intend to: - Always respond within 24 hours - Provide clear & concrete feedback - Immediately make a new release for your accepted change
License: Apache-2.0