sync: add async APIs to oneshot and mpsc (#1211)

Adds:

- oneshot::Sender::close
- mpsc::Receiver::recv
- mpsc::Sender::send

Also renames `poll_next` to `poll_recv`.

Refs: #1210
This commit is contained in:
Carl Lerche
2019-06-27 11:33:36 -07:00
committed by GitHub
parent 0af05e7408
commit 32ceccb465
10 changed files with 143 additions and 41 deletions
+9 -7
View File
@@ -67,12 +67,14 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
for arg in args {
match arg {
syn::NestedMeta::Meta(syn::Meta::Word(ident)) => match ident.to_string().to_lowercase().as_str() {
"multi_thread" => runtime = RuntimeType::Multi,
"single_thread" => runtime = RuntimeType::Single,
name => panic!("Unknown attribute {} is specified", name),
},
_ => ()
syn::NestedMeta::Meta(syn::Meta::Word(ident)) => {
match ident.to_string().to_lowercase().as_str() {
"multi_thread" => runtime = RuntimeType::Multi,
"single_thread" => runtime = RuntimeType::Single,
name => panic!("Unknown attribute {} is specified", name),
}
}
_ => (),
}
}
@@ -90,7 +92,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
let mut rt = tokio::runtime::current_thread::Runtime::new().unwrap();
rt.block_on(async { #body })
}
}
},
};
result.into()