Thread guard
This crate contains a simple thread guard.
The thread guard is used to ensure that the thread in question is always joined.
Pre-action and post-action can be defined to execute before and after thread joining, respectively. The pre-action is typically used to send a message to the thread, triggering its exit, while the post-action handles the thread's result.
In the simplest case, the guard can be used without pre-action and post-action:
use thread;
use ThreadGuard;
let guard = new;
The post-action can be used to handle the thread result:
use thread;
use ThreadGuard;
let guard = with_post_action;
If the thread needs to be signaled to exit, a pre-action can be used:
use ;
use thread;
use ThreadGuard;
let = channel;
let guard = with_pre_action;
Finally, a pre-action may need some data that outlives the appropriate
closure. An example is provided in the examples directory.