Remove secret_store runtimes. (#9888)

* Remove the independent runtimes from `KeyServerHttpListener` and
  `KeyServerCore` and instead require a `parity_runtime::Executor`
  to be passed upon creation of each.

* Remove the `threads` parameter from both `ClusterConfiguration` structs.

* Implement the `future::Executor` trait for `parity_runtime::Executor`.

* Update tests.
  - Update the `loop_until` function to instead use a oneshot to signal
    completion.
  - Modify the `make_key_servers` function to create and return a runtime.
This commit is contained in:
Nick Sanders
2018-11-25 09:36:43 -08:00
committed by Wei Tang
parent f20f4c74d2
commit c880716f16
12 changed files with 131 additions and 144 deletions

View File

@@ -16,8 +16,8 @@
//! Tokio Runtime wrapper.
extern crate futures;
extern crate tokio;
pub extern crate futures;
pub extern crate tokio;
use std::{fmt, thread};
use std::sync::mpsc;
@@ -222,6 +222,24 @@ impl Executor {
}
}
impl<F: Future<Item = (), Error = ()> + Send + 'static> future::Executor<F> for Executor {
fn execute(&self, future: F) -> Result<(), future::ExecuteError<F>> {
match self.inner {
Mode::Tokio(ref executor) => executor.execute(future),
Mode::Sync => {
let _= future.wait();
Ok(())
},
Mode::ThreadPerFuture => {
thread::spawn(move || {
let _= future.wait();
});
Ok(())
},
}
}
}
/// A handle to a runtime. Dropping the handle will cause runtime to shutdown.
pub struct RuntimeHandle {
close: Option<futures::Complete<()>>,