From 236761a3e6d82922b64d8309f823655778d998e7 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 23 Aug 2019 14:22:25 +0200 Subject: [PATCH] drop src/storage/futures.rs it's unused and uses a tokio::Task I don't want to lookup the std-future conversion for... Signed-off-by: Wolfgang Bumiller --- src/lib.rs | 2 -- src/storage/futures.rs | 63 ------------------------------------------ 2 files changed, 65 deletions(-) delete mode 100644 src/storage/futures.rs diff --git a/src/lib.rs b/src/lib.rs index 5fa1f82f..7b358b0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,9 +20,7 @@ pub mod backup; pub mod config; pub mod storage { - pub mod config; - pub mod futures; } pub mod cli; diff --git a/src/storage/futures.rs b/src/storage/futures.rs deleted file mode 100644 index 83a47771..00000000 --- a/src/storage/futures.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::sync::{Arc, Mutex}; -use std::thread; - -use failure::*; -use tokio::prelude::*; - -pub struct StorageOperation { - state: Arc>, - running: bool, -} - -impl StorageOperation { - pub fn new() -> Self { - StorageOperation { - state: Arc::new(Mutex::new(false)), - running: false, - } - } - - fn run(&mut self, task: task::Task) { - let state = self.state.clone(); - - thread::spawn(move || { - println!("state {}", state.lock().unwrap()); - println!("Starting Asnyc worker thread (delay 1 second)"); - thread::sleep(::std::time::Duration::from_secs(1)); - println!("End Asnyc worker thread"); - *state.lock().unwrap() = true; - task.notify(); - }); - } -} - -impl Future for StorageOperation { - type Item = (); - type Error = Error; - - fn poll(&mut self) -> Poll { - if *self.state.lock().unwrap() != true { - println!("not ready - parking the task."); - - if !self.running { - println!("starting storage thread"); - self.run(task::current()); - self.running = true; - } - - Ok(Async::NotReady) - } else { - println!("storage thread ready - task will complete."); - Ok(Async::Ready(())) - } - } -} - -#[test] -fn test_storage_future() { - let op = StorageOperation::new(); - hyper::rt::run(op.map_err(|e| { - println!("Got Error: {}", e); - () - })); -}