mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-01-03 01:52:30 +01:00
Change readme example to exhibit deadlock...
This commit is contained in:
@@ -9,9 +9,11 @@
|
||||
extern crate futures;
|
||||
#[macro_use]
|
||||
extern crate tarpc;
|
||||
extern crate tokio_core;
|
||||
|
||||
use futures::Future;
|
||||
use tarpc::util::Never;
|
||||
use tarpc::sync::Connect;
|
||||
use tarpc::future::Connect;
|
||||
|
||||
service! {
|
||||
rpc hello(name: String) -> String;
|
||||
@@ -27,7 +29,18 @@ impl SyncService for HelloServer {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut core = tokio_core::reactor::Core::new().unwrap();
|
||||
let addr = HelloServer.listen("localhost:10000").unwrap();
|
||||
let client = SyncClient::connect(addr).unwrap();
|
||||
println!("{}", client.hello("Mom".to_string()).unwrap());
|
||||
let f = FutureClient::connect(&addr)
|
||||
.map_err(tarpc::Error::from)
|
||||
.and_then(|client| {
|
||||
let resp1 = client.hello("Mom".to_string());
|
||||
let resp2 = client.hello("Dad".to_string());
|
||||
futures::collect(vec![resp1, resp2])
|
||||
}).map(|responses| {
|
||||
for resp in responses {
|
||||
println!("{}", resp);
|
||||
}
|
||||
});
|
||||
core.run(f).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user