projects
/
rtx3080.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
59667fb
)
Use of now() to have a precise period of time
master
author
Greg Burri
<greg.burri@gmail.com>
Wed, 16 Sep 2020 11:43:21 +0000
(13:43 +0200)
committer
Greg Burri
<greg.burri@gmail.com>
Wed, 16 Sep 2020 11:43:21 +0000
(13:43 +0200)
src/main.rs
patch
|
blob
|
history
diff --git
a/src/main.rs
b/src/main.rs
index
642a6e9
..
4854e1e
100644
(file)
--- a/
src/main.rs
+++ b/
src/main.rs
@@
-45,6
+45,7
@@
impl Config {
}
const FILE_CONF: &str = "config.ron";
}
const FILE_CONF: &str = "config.ron";
+const PULL_PERIOD: time::Duration = time::Duration::from_secs(60); // 1 min.
fn main() -> Result<()> {
println!("I need a RTX 3080 right now :)");
fn main() -> Result<()> {
println!("I need a RTX 3080 right now :)");
@@
-60,6
+61,7
@@
fn main() -> Result<()> {
let client = reqwest::blocking::Client::new();
loop {
let client = reqwest::blocking::Client::new();
loop {
+ let time_beginning_loop = time::Instant::now();
println!("Request: {}", url);
match client.get(&url).send() {
println!("Request: {}", url);
match client.get(&url).send() {
@@
-96,7
+98,12
@@
fn main() -> Result<()> {
println!("Error during request: {:?}", error)
}
println!("Error during request: {:?}", error)
}
- thread::sleep(time::Duration::from_secs(60)); // 1 min.
+ let elapsed = time::Instant::now() - time_beginning_loop;
+
+ if elapsed < PULL_PERIOD {
+ let to_wait = PULL_PERIOD - elapsed;
+ thread::sleep(to_wait);
+ }
}
}
}
}