Skip to content

Commit

Permalink
Upgrade Tokio to version 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Nov 16, 2020
1 parent 62d405a commit 59c05db
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ version = "0.17.0-rc2"
version = "0.17.0-rc2"

[dev-dependencies]
tokio = { version = "0.2", features = ["macros"] }
tokio = { version = "0.3", features = ["macros"] }
subtle-encoding = { version = "0.5" }
3 changes: 1 addition & 2 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ authors = [
[dependencies]
relayer = { path = "../relayer" }
ibc = { path = "../modules" }
abscissa_tokio = "0.5.1"
anomaly = "0.2.0"
gumdrop = "0.7"
serde = { version = "1", features = ["serde_derive"] }
thiserror = "1"
tokio = { version = "0.2.13", features = ["rt-util", "sync"] }
tokio = { version = "0.3", features = ["rt", "rt-multi-thread", "time", "stream", "sync"] }
tracing = "0.1.13"
tracing-subscriber = "0.2.3"
futures = "0.3.5"
Expand Down
8 changes: 2 additions & 6 deletions relayer-cli/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ impl Application for CliApp {
/// beyond the default ones provided by the framework, this is the place
/// to do so.
fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> {
use abscissa_tokio::TokioComponent;

let mut components = self.framework_components(command)?;
components.push(Box::new(TokioComponent::new()?));

let components = self.framework_components(command)?;
self.state.components.register(components)
}

Expand All @@ -110,4 +106,4 @@ impl Application for CliApp {
trace::Config::default()
}
}
}
}
9 changes: 5 additions & 4 deletions relayer-cli/src/commands/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use abscissa_core::{
application::fatal_error, error::BoxError, tracing::debug, Command, Options, Runnable,
};

use crate::{application::APPLICATION, prelude::*, tasks::event_listener};
use crate::{prelude::*, tasks::event_listener};

#[derive(Command, Debug, Options)]
pub struct ListenCmd {}
Expand All @@ -20,11 +20,12 @@ impl ListenCmd {

impl Runnable for ListenCmd {
fn run(&self) {
abscissa_tokio::run(&APPLICATION, async move {
let rt = tokio::runtime::Runtime::new().unwrap();

rt.block_on(async move {
self.cmd()
.await
.unwrap_or_else(|e| fatal_error(app_reader().deref(), &*e));
})
.unwrap();
});
}
}
9 changes: 5 additions & 4 deletions relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use abscissa_core::{

use relayer::{chain::CosmosSDKChain, config::Config};

use crate::{application::APPLICATION, prelude::*, tasks};
use crate::{prelude::*, tasks};

#[derive(Command, Debug, Options)]
pub struct StartCmd {
Expand All @@ -23,12 +23,13 @@ impl StartCmd {

impl Runnable for StartCmd {
fn run(&self) {
abscissa_tokio::run(&APPLICATION, async move {
let rt = tokio::runtime::Runtime::new().unwrap();

rt.block_on(async move {
self.cmd()
.await
.unwrap_or_else(|e| fatal_error(app_reader().deref(), &*e));
})
.unwrap();
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sled = { version = "0.34.4", features = ["no_metrics", "no_logs"] }
thiserror = "1.0.11"
toml = "0.5"
tracing = "0.1.13"
tokio = "0.2"
tokio = "0.3"
serde_json = { version = "1" }
bytes = "0.6.0"
prost = "0.6.1"
Expand Down
3 changes: 1 addition & 2 deletions relayer/src/util/block_on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use futures::Future;

/// Spawns a new tokio runtime and use it to block on the given future.
pub fn block_on<F: Future>(future: F) -> F::Output {
tokio::runtime::Builder::new()
.basic_scheduler()
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
Expand Down

0 comments on commit 59c05db

Please sign in to comment.