From 28d008e97c32381e18dfa029227690d58ab4ca82 Mon Sep 17 00:00:00 2001 From: nathaniel Date: Mon, 15 Apr 2019 10:02:57 -0500 Subject: [PATCH] clarify use of sleep in async_db --- async_db/src/db.rs | 8 ++++---- async_db/src/main.rs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/async_db/src/db.rs b/async_db/src/db.rs index 4ca80daf..1a0f8658 100644 --- a/async_db/src/db.rs +++ b/async_db/src/db.rs @@ -58,7 +58,7 @@ fn get_hottest_years(conn: Connection) -> Result, Error> { .collect::>()) })?; - sleep(Duration::from_secs(2)); + sleep(Duration::from_secs(2)); //see comments at top of main.rs Ok(annuals) } @@ -84,7 +84,7 @@ fn get_coldest_years(conn: Connection) -> Result, Error> { .collect::>()) })?; - sleep(Duration::from_secs(2)); + sleep(Duration::from_secs(2)); //see comments at top of main.rs Ok(annuals) } @@ -111,7 +111,7 @@ fn get_hottest_months(conn: Connection) -> Result, Error> { .collect::>()) })?; - sleep(Duration::from_secs(2)); + sleep(Duration::from_secs(2)); //see comments at top of main.rs Ok(annuals) } @@ -137,6 +137,6 @@ fn get_coldest_months(conn: Connection) -> Result, Error> { .collect::>()) })?; - sleep(Duration::from_secs(2)); + sleep(Duration::from_secs(2)); //see comments at top of main.rs Ok(annuals) } diff --git a/async_db/src/main.rs b/async_db/src/main.rs index b2293fed..99cc6f8d 100644 --- a/async_db/src/main.rs +++ b/async_db/src/main.rs @@ -8,6 +8,8 @@ This project illustrates two examples: 2. An asynchronous handler that executes 4 queries in *parallel*, collecting the results and returning them as a single serialized json object + Note: The use of sleep(Duration::from_secs(2)); in db.rs is to make performance + improvement with parallelism more obvious. */ use std::io;