run-down

The run-down crate provides an implementation of run-down protection.
Overview
Run-down protection as a pattern is useful in situations where re-initialization or destruction of a shared resource is required in a SMP environment.
The pattern has two parts, a means to guarantee the resource is accessible and remains so for the during of it's usage. As well as way to make the resource inaccessible from a point going forward and the ability to wait for all outstanding usages to drain so you can safely perform the required operation.
This crate was inspired by the run-down protection primitive in the NT kernel. Where it's used in situations such as driver unload, where futher access to the driver needs to be rejected and the unloading thread must wait for inflight acesss to stop before the driver can be completely unload.
Documentation
Example
use ;
use Arc;
use thread;
use Duration;
let rundown = new;
for i in 1..25
println!;
rundown.wait_for_rundown;
println!;
TODO
-
Add a more interesting real-world example.
-
Add some benchmarks to see if there is any opportunity to optimize the implementation.
Note: This crate is not created by, affiliated with, or supported by Microsoft.