Skip to content

Commit

Permalink
Use tokio::spawn in routeguide
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioFranco committed Sep 21, 2019
1 parent df8e0a0 commit 322f346
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tonic-examples/src/routeguide/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,17 @@ impl server::RouteGuide for RouteGuide {
&self,
request: Request<Rectangle>,
) -> Result<Response<Self::ListFeaturesStream>, Status> {
use std::thread;

println!("ListFeatures = {:?}", request);

let (mut tx, rx) = mpsc::channel(4);

let state = self.state.clone();

thread::spawn(move || {
tokio::spawn(async move {
for feature in &state.features[..] {
if in_range(feature.location.as_ref().unwrap(), request.get_ref()) {
println!(" => send {:?}", feature);
tx.try_send(Ok(feature.clone())).unwrap();
tx.send(Ok(feature.clone())).await.unwrap();
}
}

Expand Down

0 comments on commit 322f346

Please sign in to comment.