Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(await_macro, async_await, futures_api)]
- use std::future::Future;
- use std::sync::Mutex;
- use std::sync::Arc;
- use tokio::{runtime::Runtime};
- async fn do_nothing() {
- }
- async fn foo(count: Arc<Mutex<u32>>) {
- let mut x = count.lock().unwrap();
- *x += 1;
- drop(x);
- await!(do_nothing());
- }
- fn main() {
- let runtime = Runtime::new().unwrap();
- let executor = runtime.executor();
- let x = Arc::new(Mutex::new(0));
- executor.spawn(foo(x.clone()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement