macro_rules! run_as {
($mode:path, $ret:ty, $body:block) => { ... };
($mode:path, $body:block) => { ... };
($mode:path, $expr:expr) => { ... };
}Expand description
This is a thread-safe wrapper that sets the mode, runs the closure/expression, then returns to the mode before the call. You can use this in multi-threaded environments, and it is guaranteed the content of the closure/expression will be run under the requested Mode.