aboutsummaryrefslogtreecommitdiff
path: root/src/run.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/run.rs')
-rw-r--r--src/run.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/run.rs b/src/run.rs
index 3a5186b..2ec6889 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -7,15 +7,13 @@ use async_std::task;
use async_std::task::sleep;
use futures::future;
use futures::stream::StreamExt;
-use std::time::Duration;
use std::future::Future;
-
-
+use std::time::Duration;
async fn init_block<F, Fut>(tx: Sender<ThreadsData>, block: F, delay: f64)
where
F: Fn() -> Fut,
- Fut: Future<Output=ThreadsData>
+ Fut: Future<Output = ThreadsData>,
{
loop {
let _ = tx.send(block().await).await;
@@ -37,6 +35,12 @@ pub async fn run(mut blocks: BlockManager) {
task::spawn(b);
}
+ // local ip task
+ if CONFIG.local_ip.enabled {
+ let b = init_block(tx.clone(), local_ip::get_local_ip, CONFIG.local_ip.delay);
+ task::spawn(b);
+ }
+
// spotify task
if CONFIG.spotify.enabled {
let b = init_block(tx.clone(), spotify::get_spotify, CONFIG.spotify.delay);
@@ -56,17 +60,13 @@ pub async fn run(mut blocks: BlockManager) {
}
// Disk task
- if
- /*CONFIG.disk.enabled*/
- false {
+ if CONFIG.disk.enabled {
let b = init_block(tx.clone(), disk::get_disk, CONFIG.disk.delay);
task::spawn(b);
}
// Memory task
- if
- /*CONFIG.memory.enabled*/
- false {
+ if CONFIG.memory.enabled {
let b = init_block(tx.clone(), memory::get_memory, CONFIG.memory.delay);
task::spawn(b);
}
@@ -111,8 +111,6 @@ pub async fn run(mut blocks: BlockManager) {
let b = init_block(tx, time::get_time, CONFIG.time.delay);
task::spawn(b);
- // NOTE: order matters to the final format
-
rx.for_each(|data| {
blocks.update(data);
future::ready(())