Skip to content

Commit

Permalink
use: spawn_local
Browse files Browse the repository at this point in the history
  • Loading branch information
S0c5 committed Jul 25, 2024
1 parent 93196e2 commit 2afcbca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
17 changes: 6 additions & 11 deletions sube/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ async-mutex = { version = "1.4.0", optional = true }
async-tls = { version = "0.11.0", default-features = false, optional = true }

# bin target
async-std = { version = "1.12.0", default-features = false, optional = true, features = [
"attributes",
"alloc"
] }
async-std = { version = "1.11.0", default-features = false, optional = true }
paste = { version = "1.0", optional = true }
wasm-bindgen = { version = "0.2.91", optional = true }
once_cell = { version = "1.17.1", optional = true }
Expand All @@ -61,11 +58,9 @@ rand_core = { version = "0.6.3", optional = true }
ewebsock = { git = "https://github.com/S0c5/ewebsock.git", optional = true, branch = "enhacement/aviod-blocking-operations-with-mpsc-futures" }
env_logger = "0.11.3"


[dev-dependencies]
async-std = { version = "1.12.0", default-features = false, features = [
"attributes",
"alloc"
] }
async-std = { version = "1.11.0", features = ["attributes"] }
hex-literal = "0.3.4"
libwallet = { path = "../libwallet", default-features = false, features = [
"substrate",
Expand Down Expand Up @@ -94,11 +89,11 @@ ws = [
"dep:futures-channel",
"dep:futures-util",
"dep:jsonrpc",
"dep:async-std",
"async-std/unstable",
]
wss = ["dep:async-tls", "ws", "ewebsock/tls", "dep:async-std"]
wss = ["dep:async-tls", "ws", "ewebsock/tls", "async-std/unstable"]
examples = ["dep:rand_core"]
js = ["json", "v14", 'dep:async-std', "ws", "dep:rand_core"]
js = ["http-web", "json", "v14", 'async-std/unstable', "ws", "dep:rand_core"]

[package.metadata.docs.rs]
features = ["http"]
Expand Down
12 changes: 1 addition & 11 deletions sube/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@ use serde::Deserialize;
#[cfg(not(feature = "js"))]
use async_std::task::spawn;
#[cfg(feature = "js")]
use async_std::task::{Builder, JoinHandle};

#[cfg(feature = "js")]
pub fn spawn_local<F, T>(future: F) -> JoinHandle<T>
where
F: futures_util::Future<Output = T> + 'static,
T: 'static,
{
#[cfg(feature = "js")]
Builder::new().local(future).expect("cannot spawn task")
}
use async_std::task::spawn_local as spawn;

use crate::{
rpc::{self, Rpc, RpcResult},
Expand Down

0 comments on commit 2afcbca

Please sign in to comment.