1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

upgrade misc deps, notably, async-task

This commit is contained in:
Wez Furlong 2020-10-05 00:06:01 -07:00
parent 3e2b86e15e
commit 5eb4d32004
32 changed files with 246 additions and 378 deletions

273
Cargo.lock generated
View File

@ -304,7 +304,7 @@ dependencies = [
"async-io",
"async-mutex",
"blocking",
"crossbeam-utils 0.7.2",
"crossbeam-utils",
"futures-channel",
"futures-core",
"futures-io",
@ -514,12 +514,6 @@ version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]]
name = "bytes"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]]
name = "cache-padded"
version = "1.1.1"
@ -589,7 +583,7 @@ dependencies = [
"atty",
"bitflags 1.2.1",
"strsim 0.8.0",
"textwrap",
"textwrap 0.11.0",
"unicode-width",
"vec_map",
]
@ -830,20 +824,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e"
dependencies = [
"cfg-if",
"crossbeam-channel 0.4.4",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils 0.7.2",
]
[[package]]
name = "crossbeam-channel"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa"
dependencies = [
"crossbeam-utils 0.6.6",
"crossbeam-utils",
]
[[package]]
@ -852,7 +837,7 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87"
dependencies = [
"crossbeam-utils 0.7.2",
"crossbeam-utils",
"maybe-uninit",
]
@ -863,7 +848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils 0.7.2",
"crossbeam-utils",
"maybe-uninit",
]
@ -875,7 +860,7 @@ checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [
"autocfg 1.0.1",
"cfg-if",
"crossbeam-utils 0.7.2",
"crossbeam-utils",
"lazy_static",
"maybe-uninit",
"memoffset",
@ -889,20 +874,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if",
"crossbeam-utils 0.7.2",
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
name = "crossbeam-utils"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
dependencies = [
"cfg-if",
"lazy_static",
]
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
@ -1083,28 +1058,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "failure"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
dependencies = [
"backtrace",
"failure_derive",
]
[[package]]
name = "failure_derive"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.42",
"synstructure",
]
[[package]]
name = "fastrand"
version = "1.4.0"
@ -1513,15 +1466,15 @@ dependencies = [
[[package]]
name = "hdrhistogram"
version = "6.3.4"
version = "7.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d331ebcdbca4acbefe5da8c3299b2e246f198a8294cc5163354e743398b89d"
checksum = "b3c22708574c44e924720c5b3a116326c688e6d532f438c77c007ec8768644f9"
dependencies = [
"base64 0.10.1",
"base64 0.12.3",
"byteorder",
"crossbeam-channel 0.3.9",
"crossbeam-channel",
"flate2",
"nom 4.2.3",
"nom",
"num-traits 0.2.12",
]
@ -1737,6 +1690,19 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"
[[package]]
name = "lexical-core"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616"
dependencies = [
"arrayvec 0.5.1",
"bitflags 1.2.1",
"cfg-if",
"ryu",
"static_assertions",
]
[[package]]
name = "libc"
version = "0.2.79"
@ -1998,7 +1964,7 @@ dependencies = [
"kernel32-sys",
"libc",
"log",
"miow 0.2.1",
"miow",
"net2",
"slab",
"winapi 0.2.8",
@ -2016,29 +1982,6 @@ dependencies = [
"slab",
]
[[package]]
name = "mio-named-pipes"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656"
dependencies = [
"log",
"mio",
"miow 0.3.5",
"winapi 0.3.9",
]
[[package]]
name = "mio-uds"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
dependencies = [
"iovec",
"libc",
"mio",
]
[[package]]
name = "miow"
version = "0.2.1"
@ -2051,16 +1994,6 @@ dependencies = [
"ws2_32-sys",
]
[[package]]
name = "miow"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e"
dependencies = [
"socket2",
"winapi 0.3.9",
]
[[package]]
name = "mlua"
version = "0.2.2"
@ -2149,24 +2082,15 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "nom"
version = "4.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
dependencies = [
"memchr",
"version_check 0.1.5",
]
[[package]]
name = "nom"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [
"lexical-core",
"memchr",
"version_check 0.9.2",
"version_check",
]
[[package]]
@ -2515,18 +2439,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "pem"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39eb474073dfddbf7156515344266245d91ce698ddbf15e0498cef22b836f45a"
dependencies = [
"base64 0.10.1",
"failure",
"lazy_static",
"regex",
]
[[package]]
name = "pem"
version = "0.8.1"
@ -2705,7 +2617,7 @@ dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.42",
"version_check 0.9.2",
"version_check",
]
[[package]]
@ -2716,7 +2628,7 @@ checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"version_check 0.9.2",
"version_check",
]
[[package]]
@ -2755,18 +2667,17 @@ version = "0.2.0"
dependencies = [
"anyhow",
"async-std",
"async-task 1.3.1",
"async-task 4.0.2",
"crossbeam",
"lazy_static",
"thiserror",
"tokio",
]
[[package]]
name = "pulldown-cmark"
version = "0.7.2"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55"
checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
dependencies = [
"bitflags 1.2.1",
"getopts",
@ -2927,25 +2838,13 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf"
dependencies = [
"crossbeam-channel 0.4.4",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils 0.7.2",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
[[package]]
name = "rcgen"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d6cbbf5f43710b9242a4897f4671a469198e2d826d9df043fc16e046f45d8a"
dependencies = [
"chrono",
"pem 0.6.1",
"ring",
"yasna",
]
[[package]]
name = "rcgen"
version = "0.8.5"
@ -2953,7 +2852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4974f7e96ee51fa3c90c3022e02c3a7117e71cb2a84518a55e44360135200c25"
dependencies = [
"chrono",
"pem 0.8.1",
"pem",
"ring",
"yasna",
]
@ -3071,7 +2970,7 @@ dependencies = [
"base64 0.12.3",
"blake2b_simd",
"constant_time_eq",
"crossbeam-utils 0.7.2",
"crossbeam-utils",
]
[[package]]
@ -3380,18 +3279,6 @@ dependencies = [
"once_cell",
]
[[package]]
name = "socket2"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"winapi 0.3.9",
]
[[package]]
name = "spin"
version = "0.5.2"
@ -3416,6 +3303,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strip-ansi-escapes"
version = "0.1.0"
@ -3518,18 +3411,6 @@ dependencies = [
"unicode-xid 0.0.4",
]
[[package]]
name = "synstructure"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.42",
"unicode-xid 0.2.1",
]
[[package]]
name = "tabout"
version = "0.3.0"
@ -3570,7 +3451,7 @@ checksum = "76971977e6121664ec1b960d1313aacfa75642adc93b9d4d53b247bd4cb1747e"
dependencies = [
"dirs 2.0.2",
"fnv",
"nom 5.1.2",
"nom",
"phf",
"phf_codegen",
]
@ -3635,6 +3516,15 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "textwrap"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [
"unicode-width",
]
[[package]]
name = "thiserror"
version = "1.0.20"
@ -3692,46 +3582,11 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117"
[[package]]
name = "tokio"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd"
dependencies = [
"bytes",
"fnv",
"futures-core",
"iovec",
"lazy_static",
"libc",
"memchr",
"mio",
"mio-named-pipes",
"mio-uds",
"num_cpus",
"pin-project-lite",
"signal-hook-registry",
"slab",
"tokio-macros",
"winapi 0.3.9",
]
[[package]]
name = "tokio-macros"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.42",
]
[[package]]
name = "toml"
version = "0.4.10"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
dependencies = [
"serde",
]
@ -3767,7 +3622,7 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check 0.9.2",
"version_check",
]
[[package]]
@ -3886,12 +3741,6 @@ dependencies = [
"chrono",
]
[[package]]
name = "version_check"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
[[package]]
name = "version_check"
version = "0.9.2"
@ -4205,7 +4054,6 @@ dependencies = [
"pulldown-cmark",
"rangeset",
"ratelim",
"rcgen 0.7.0",
"regex",
"serde",
"serde_json",
@ -4217,10 +4065,9 @@ dependencies = [
"tabout",
"terminfo",
"termwiz",
"textwrap",
"textwrap 0.12.1",
"thiserror",
"tinyvec",
"toml",
"uds_windows",
"umask",
"unicode-normalization",
@ -4253,7 +4100,7 @@ dependencies = [
"pretty_env_logger",
"promise",
"rangeset",
"rcgen 0.8.5",
"rcgen",
"smol",
"structopt",
"uds_windows",
@ -4465,7 +4312,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3a481cfdefd35e1c50073ae33a8000d695c98039544659f5dc5dd71311b0d01"
dependencies = [
"nom 5.1.2",
"nom",
]
[[package]]

View File

@ -25,6 +25,6 @@ notify = "4.0"
portable-pty = { path = "../pty", features = ["serde_support"]}
serde = {version="1.0", features = ["rc", "derive"]}
termwiz = { path = "../termwiz" }
toml = "0.4"
toml = "0.5"
wezterm-term = { path = "../term", features=["use_serde"] }
mlua = {version="0.2", features=["vendored"]}

View File

@ -87,7 +87,8 @@ fn read_from_pane_pty(pane_id: PaneId, mut reader: Box<dyn std::io::Read>) {
dead.store(true, Ordering::Relaxed);
}
}
});
})
.detach();
}
Err(delay) => {
log::trace!("RateLimiter: sleep for {:?}", delay);
@ -101,7 +102,8 @@ fn read_from_pane_pty(pane_id: PaneId, mut reader: Box<dyn std::io::Read>) {
promise::spawn::spawn_into_main_thread(async move {
let mux = Mux::get().unwrap();
mux.remove_pane(pane_id);
});
})
.detach();
}
thread_local! {
@ -122,7 +124,8 @@ impl Drop for MuxWindowBuilder {
mux.notify(MuxNotification::WindowCreated(window_id));
drop(activity);
}
});
})
.detach();
}
}

View File

@ -61,7 +61,8 @@ fn schedule_next_paste(paste: &Arc<Mutex<Paste>>) {
locked.offset += chunk;
schedule_next_paste(&paste);
}
});
})
.detach();
}
/// A Pane represents a view on a terminal

View File

@ -1171,7 +1171,8 @@ impl Tab {
for pane_id in dead_panes.into_iter() {
mux.remove_pane(pane_id);
}
});
})
.detach();
true
} else {
false

View File

@ -5,10 +5,9 @@ version = "0.2.0"
edition = "2018"
[dependencies]
async-task = "1.2"
async-task = "4.0"
async-std = "1.4"
crossbeam = "0.7"
tokio = {version="0.2", features=["full"]}
anyhow = "1.0"
thiserror = "1.0"
lazy_static = "1.3"

View File

@ -1,21 +1,21 @@
use crate::SpawnFunc;
use anyhow::{anyhow, Result};
use async_task::{JoinHandle, Task};
use async_task::Runnable;
use std::future::Future;
use std::sync::mpsc::{sync_channel, Receiver, TryRecvError};
use std::sync::{Arc, Mutex};
use std::task::{Poll, Waker};
pub type ScheduleFunc = Box<dyn Fn(Task<()>) + Send + Sync + 'static>;
pub use async_task::Task;
pub type ScheduleFunc = Box<dyn Fn(Runnable) + Send + Sync + 'static>;
fn no_schedule_configured(_: Task<()>) {
fn no_schedule_configured(_: Runnable) {
panic!("no scheduler has been configured");
}
lazy_static::lazy_static! {
static ref ON_MAIN_THREAD: Mutex<ScheduleFunc> = Mutex::new(Box::new(no_schedule_configured));
static ref ON_MAIN_THREAD_LOW_PRI: Mutex<ScheduleFunc> = Mutex::new(Box::new(no_schedule_configured));
static ref TOKIO: tokio::runtime::Handle = start_tokio();
}
/// Set callbacks for scheduling normal and low priority futures.
@ -30,59 +30,12 @@ pub fn set_schedulers(main: ScheduleFunc, low_pri: ScheduleFunc) {
*ON_MAIN_THREAD_LOW_PRI.lock().unwrap() = Box::new(low_pri);
}
/// Spawn the tokio runtime and run it on a secondary thread.
/// We can't run it on the main thread for the reasons mentioned above.
/// This is called implicitly when the TOKIO global is accessed by the
/// `tokio_spawn` function below.
fn start_tokio() -> tokio::runtime::Handle {
let mut runtime = tokio::runtime::Builder::new()
.threaded_scheduler()
.core_threads(1)
.build()
.expect("failed to initialize tokio runtime");
let handle = runtime.handle().clone();
// Run the runtime in another thread.
// I'm not sure that it is strictly needed, or whether we can just
// keep it alive without actively polling anything.
std::thread::spawn(move || {
// A future that never completes
struct Never {}
impl Future for Never {
type Output = ();
fn poll(
self: std::pin::Pin<&mut Self>,
_: &mut std::task::Context,
) -> Poll<Self::Output> {
Poll::Pending
}
}
// manage the runtime forever
runtime.block_on(Never {});
});
handle
}
/// Spawn a future into the tokio runtime, spawning the tokio runtime
/// if it hasn't already been started up. The tokio runtime (in the
/// context of this crate) is intended primarily for scheduling network
/// IO. Most futures should be spawned via the other functions provided
/// by this module.
pub fn tokio_spawn<F>(future: F) -> tokio::task::JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
TOKIO.spawn(future)
}
/// Spawn a new thread to execute the provided function.
/// Returns a JoinHandle that implements the Future trait
/// and that can be used to await and yield the return value
/// from the thread.
/// Can be called from any thread.
pub fn spawn_into_new_thread<F, T>(f: F) -> JoinHandle<Result<T>, ()>
pub fn spawn_into_new_thread<F, T>(f: F) -> Task<Result<T>>
where
F: FnOnce() -> Result<T>,
F: Send + 'static,
@ -147,14 +100,15 @@ where
/// This function can be called from any thread.
/// If you are on the main thread already, consider using
/// spawn() instead to lift the `Send` requirement.
pub fn spawn_into_main_thread<F, R>(future: F) -> JoinHandle<R, ()>
pub fn spawn_into_main_thread<F, R>(future: F) -> Task<R>
where
F: Future<Output = R> + Send + 'static,
R: Send + 'static,
{
let (task, handle) = async_task::spawn(future, |task| ON_MAIN_THREAD.lock().unwrap()(task), ());
task.schedule();
handle
let (runnable, task) =
async_task::spawn(future, |runnable| ON_MAIN_THREAD.lock().unwrap()(runnable));
ON_MAIN_THREAD.lock().unwrap()(runnable);
task
}
/// Spawn a future into the main thread; it will be polled in
@ -163,56 +117,54 @@ where
/// spawns.
/// If you are on the main thread already, consider using `spawn_with_low_priority`
/// instead to lift the `Send` requirement.
pub fn spawn_into_main_thread_with_low_priority<F, R>(future: F) -> JoinHandle<R, ()>
pub fn spawn_into_main_thread_with_low_priority<F, R>(future: F) -> Task<R>
where
F: Future<Output = R> + Send + 'static,
R: Send + 'static,
{
let (task, handle) = async_task::spawn(
future,
|task| ON_MAIN_THREAD_LOW_PRI.lock().unwrap()(task),
(),
);
task.schedule();
handle
let (runnable, task) = async_task::spawn(future, |runnable| {
ON_MAIN_THREAD_LOW_PRI.lock().unwrap()(runnable)
});
ON_MAIN_THREAD_LOW_PRI.lock().unwrap()(runnable);
task
}
/// Spawn a future with normal priority.
pub fn spawn<F, R>(future: F) -> JoinHandle<R, ()>
pub fn spawn<F, R>(future: F) -> Task<R>
where
F: Future<Output = R> + 'static,
R: 'static,
{
let (task, handle) =
async_task::spawn_local(future, |task| ON_MAIN_THREAD.lock().unwrap()(task), ());
task.schedule();
handle
let (runnable, task) =
async_task::spawn_local(future, |runnable| ON_MAIN_THREAD.lock().unwrap()(runnable));
ON_MAIN_THREAD.lock().unwrap()(runnable);
task
}
/// Spawn a future with low priority; it will be polled only after
/// all other normal priority items are processed.
pub fn spawn_with_low_priority<F, R>(future: F) -> JoinHandle<R, ()>
pub fn spawn_with_low_priority<F, R>(future: F) -> Task<R>
where
F: Future<Output = R> + 'static,
R: 'static,
{
let (task, handle) = async_task::spawn_local(
future,
|task| ON_MAIN_THREAD_LOW_PRI.lock().unwrap()(task),
(),
);
task.schedule();
handle
let (runnable, task) = async_task::spawn_local(future, |runnable| {
ON_MAIN_THREAD_LOW_PRI.lock().unwrap()(runnable)
});
ON_MAIN_THREAD_LOW_PRI.lock().unwrap()(runnable);
task
}
/// Block the current thread until the passed future completes.
pub use async_std::task::block_on;
/*
pub async fn join_handle_result<T>(handle: JoinHandle<anyhow::Result<T>, ()>) -> anyhow::Result<T> {
handle
.await
.ok_or_else(|| anyhow::anyhow!("task was cancelled or panicked"))?
}
*/
pub struct SimpleExecutor {
rx: crossbeam::channel::Receiver<SpawnFunc>,
@ -231,8 +183,16 @@ impl SimpleExecutor {
tx_low.send(f).ok();
};
set_schedulers(
Box::new(move |task| queue_func(Box::new(move || task.run()))),
Box::new(move |task| queue_func_low(Box::new(move || task.run()))),
Box::new(move |task| {
queue_func(Box::new(move || {
task.run();
}))
}),
Box::new(move |task| {
queue_func_low(Box::new(move || {
task.run();
}))
}),
);
Self { rx }
}

View File

@ -26,7 +26,8 @@ impl LocalListener {
log::error!("{:#}", e);
e
})
});
})
.detach();
}
Err(err) => {
log::error!("accept failed: {}", err);

View File

@ -120,7 +120,8 @@ fn run() -> anyhow::Result<()> {
terminate_with_error(err);
}
drop(activity);
});
})
.detach();
loop {
executor.tick()?;

View File

@ -90,7 +90,8 @@ impl OpenSSLNetListener {
log::error!("process: {:?}", e);
e
})
});
})
.detach();
}
Err(e) => {
log::error!("failed TlsAcceptor: {}", e);

View File

@ -183,7 +183,8 @@ impl SessionHandler {
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
maybe_push_pane_changes(&pane, sender, per_pane)?;
Ok::<(), anyhow::Error>(())
});
})
.detach();
}
pub fn process_one(&mut self, decoded: DecodedPdu) {
@ -229,7 +230,8 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::WriteToPane(WriteToPane { pane_id, data }) => {
@ -248,7 +250,8 @@ impl SessionHandler {
},
send_response,
);
});
})
.detach();
}
Pdu::SendPaste(SendPaste { pane_id, data }) => {
let sender = self.to_write_tx.clone();
@ -266,7 +269,8 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::SearchScrollbackRequest(SearchScrollbackRequest { pane_id, pattern }) => {
@ -287,8 +291,10 @@ impl SessionHandler {
promise::spawn::spawn(async move {
let result = do_search(pane_id, pattern).await;
send_response(result);
});
});
})
.detach();
})
.detach();
}
Pdu::SetPaneZoomed(SetPaneZoomed {
@ -312,7 +318,8 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::Resize(Resize {
@ -336,7 +343,8 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::SendKeyDown(SendKeyDown {
@ -370,7 +378,8 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::SendMouseEvent(SendMouseEvent { pane_id, event }) => {
let sender = self.to_write_tx.clone();
@ -388,21 +397,24 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::Spawn(spawn) => {
let sender = self.to_write_tx.clone();
spawn_into_main_thread(async move {
schedule_domain_spawn(spawn, sender, send_response);
});
})
.detach();
}
Pdu::SplitPane(split) => {
let sender = self.to_write_tx.clone();
spawn_into_main_thread(async move {
schedule_split_pane(split, sender, send_response);
});
})
.detach();
}
Pdu::GetPaneRenderChanges(GetPaneRenderChanges { pane_id, .. }) => {
@ -426,7 +438,8 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::GetLines(GetLines { pane_id, lines }) => {
@ -458,7 +471,8 @@ impl SessionHandler {
},
send_response,
)
});
})
.detach();
}
Pdu::GetCodecVersion(_) => {
@ -509,14 +523,14 @@ fn schedule_domain_spawn<SND>(spawn: Spawn, sender: PduSender, send_response: SN
where
SND: Fn(anyhow::Result<Pdu>) + 'static,
{
promise::spawn::spawn(async move { send_response(domain_spawn(spawn, sender).await) });
promise::spawn::spawn(async move { send_response(domain_spawn(spawn, sender).await) }).detach();
}
fn schedule_split_pane<SND>(split: SplitPane, sender: PduSender, send_response: SND)
where
SND: Fn(anyhow::Result<Pdu>) + 'static,
{
promise::spawn::spawn(async move { send_response(split_pane(split, sender).await) });
promise::spawn::spawn(async move { send_response(split_pane(split, sender).await) }).detach();
}
struct RemoteClipboard {

View File

@ -42,17 +42,16 @@ log = "0.4"
lru = "0.5"
luahelper = { path = "../luahelper" }
mux = { path = "../mux" }
open = "1.2"
pulldown-cmark = "0.7"
open = "1.4"
pulldown-cmark = "0.8"
metrics = { version="0.12", features=["std"]}
mlua = {version="0.2", features=["vendored"]}
hdrhistogram = "6.3"
hdrhistogram = "7.1"
openssl = "0.10"
palette = "0.5"
portable-pty = { path = "../pty", features = ["serde_support", "ssh"]}
promise = { path = "../promise" }
ratelim= { path = "../ratelim" }
rcgen = "0.7"
smol = "1.2"
http_req = {version="0.6", default-features=false, features=["rust-tls"]}
regex = "1"
@ -65,9 +64,8 @@ tabout = { path = "../tabout" }
wezterm-term = { path = "../term", features=["use_serde"] }
terminfo = "0.7"
termwiz = { path = "../termwiz" }
textwrap = "0.11"
tinyvec = "0.3"
toml = "0.4"
textwrap = "0.12"
tinyvec = "0.3" # Note: constrained by the allsorts crate
umask = { path = "../umask" }
unicode-normalization = "0.1"
unicode-segmentation = "1.6"

View File

@ -258,7 +258,8 @@ impl ConnectionUI {
.ok();
}
Ok(())
}));
}))
.detach();
Self { tx }
}

View File

@ -40,7 +40,8 @@ pub fn confirm_close_pane(
None => return,
};
tab.kill_pane(pane_id);
});
})
.detach();
break;
}
InputEvent::Key(KeyEvent {
@ -88,7 +89,8 @@ pub fn confirm_close_tab(
promise::spawn::spawn_into_main_thread(async move {
let mux = Mux::get().unwrap();
mux.remove_tab(tab_id);
});
})
.detach();
break;
}
InputEvent::Key(KeyEvent {

View File

@ -218,7 +218,8 @@ pub fn launcher(
mux_window_id,
clipboard,
);
});
})
.detach();
}
Entry::Attach { domain, .. } => {
promise::spawn::spawn_into_main_thread(async move {
@ -226,7 +227,8 @@ pub fn launcher(
// because the compiler would then want its body
// to be Send :-/
do_domain_attach(domain);
});
})
.detach();
}
}
}
@ -297,5 +299,6 @@ fn do_domain_attach(domain: DomainId) {
.get_domain(domain)
.ok_or_else(|| anyhow!("launcher attach called with unresolvable domain id!?"))?;
domain.attach().await
});
})
.detach();
}

View File

@ -24,7 +24,7 @@ pub fn start_overlay<T, F>(
func: F,
) -> (
Rc<dyn Pane>,
Pin<Box<dyn std::future::Future<Output = Option<anyhow::Result<T>>>>>,
Pin<Box<dyn std::future::Future<Output = anyhow::Result<T>>>>,
)
where
T: Send + 'static,
@ -51,7 +51,7 @@ pub fn start_overlay_pane<T, F>(
func: F,
) -> (
Rc<dyn Pane>,
Pin<Box<dyn std::future::Future<Output = Option<anyhow::Result<T>>>>>,
Pin<Box<dyn std::future::Future<Output = anyhow::Result<T>>>>,
)
where
T: Send + 'static,

View File

@ -372,7 +372,8 @@ impl SearchRenderable {
Ok(())
});
anyhow::Result::<()>::Ok(())
});
})
.detach();
} else {
self.set_viewport(None);
self.clear_selection();

View File

@ -82,7 +82,8 @@ pub fn tab_navigator(
window.set_active(idx);
anyhow::Result::<()>::Ok(())
});
})
.detach();
true
}
}

View File

@ -1454,7 +1454,7 @@ impl TermWindow {
tab_navigator(tab_id, term, tabs, mux_window_id)
});
self.assign_overlay(tab.tab_id(), overlay);
promise::spawn::spawn(future);
promise::spawn::spawn(future).detach();
}
fn show_launcher(&mut self) {
@ -1518,7 +1518,7 @@ impl TermWindow {
)
});
self.assign_overlay(tab.tab_id(), overlay);
promise::spawn::spawn(future);
promise::spawn::spawn(future).detach();
}
fn scroll_by_page(&mut self, amount: isize) -> anyhow::Result<()> {
@ -1720,7 +1720,8 @@ impl TermWindow {
drop(activity);
Ok(())
});
})
.detach();
}
fn spawn_tab(&mut self, domain: &SpawnTabDomain) {
@ -1782,7 +1783,8 @@ impl TermWindow {
Ok(())
});
}
});
})
.detach();
}
fn perform_key_assignment(
@ -1879,7 +1881,8 @@ impl TermWindow {
if let Err(err) = open::that(link.uri()) {
log::error!("failed to open {}: {:?}", link.uri(), err);
}
});
})
.detach();
}
}
CompleteSelectionOrOpenLinkAtMouseCursor => {
@ -1969,7 +1972,8 @@ impl TermWindow {
}
promise::spawn::spawn(async move {
new_window().await.ok();
});
})
.detach();
}
fn apply_scale_change(&mut self, dimensions: &Dimensions, font_scale: f64) {
@ -2136,7 +2140,7 @@ impl TermWindow {
confirm_close_pane(pane_id, term, mux_window_id)
});
self.assign_overlay_for_pane(pane_id, overlay);
promise::spawn::spawn(future);
promise::spawn::spawn(future).detach();
} else {
tab.kill_pane(pane_id);
}
@ -2155,7 +2159,7 @@ impl TermWindow {
confirm_close_tab(tab_id, term, mux_window_id)
});
self.assign_overlay(tab_id, overlay);
promise::spawn::spawn(future);
promise::spawn::spawn(future).detach();
} else {
mux.remove_tab(tab_id);
}

View File

@ -348,7 +348,8 @@ fn run_ssh(config: config::ConfigHandle, opts: SshCommand) -> anyhow::Result<()>
// ensures that we drop it either when we error out, or if not,
// only once we reach this point in the processing flow.
drop(activity);
});
})
.detach();
maybe_show_configuration_error_window();
gui.run_forever()
@ -427,7 +428,8 @@ fn run_mux_client(config: config::ConfigHandle, opts: &ConnectCommand) -> anyhow
terminate_with_error(err);
}
drop(activity);
});
})
.detach();
gui.run_forever()
}
@ -521,7 +523,8 @@ fn run_terminal_gui(config: config::ConfigHandle, opts: StartCommand) -> anyhow:
terminate_with_error(err);
}
drop(activity);
});
})
.detach();
maybe_show_configuration_error_window();
gui.run_forever()
@ -558,7 +561,8 @@ fn toast_notification(title: &str, message: &str) {
.duration(winrt_notification::Duration::Long)
.show()
.ok();
});
})
.detach();
}
}
@ -930,7 +934,8 @@ fn run_cli(config: config::ConfigHandle, cli: CliCommand) -> anyhow::Result<()>
terminate_with_error(err);
}
}
});
})
.detach();
loop {
executor.tick()?;
}

View File

@ -99,7 +99,8 @@ fn process_unilateral_inner(pane_id: PaneId, local_domain_id: DomainId, decoded:
promise::spawn::spawn(async move {
process_unilateral_inner_async(pane_id, local_domain_id, decoded).await?;
Ok::<(), anyhow::Error>(())
});
})
.detach();
}
async fn process_unilateral_inner_async(
@ -161,7 +162,8 @@ fn process_unilateral(local_domain_id: DomainId, decoded: DecodedPdu) -> anyhow:
if let Some(pane_id) = decoded.pdu.pane_id() {
promise::spawn::spawn_into_main_thread(async move {
process_unilateral_inner(pane_id, local_domain_id, decoded)
});
})
.detach();
} else {
bail!("don't know how to handle {:?}", decoded);
}
@ -802,7 +804,8 @@ impl Client {
log::error!("Reconnected!");
promise::spawn::spawn_into_main_thread(async move {
ClientDomain::reattach(local_domain_id, ui).await.ok();
});
})
.detach();
break;
}
Err(err) => {
@ -837,7 +840,8 @@ impl Client {
}
promise::spawn::spawn_into_main_thread(async move {
detach(local_domain_id).await.ok();
});
})
.detach();
});
Self {

View File

@ -12,7 +12,7 @@ use mux::tab::{SplitDirection, Tab, TabId};
use mux::window::WindowId;
use mux::Mux;
use portable_pty::{CommandBuilder, PtySize};
use promise::spawn::{join_handle_result, spawn_into_new_thread};
use promise::spawn::spawn_into_new_thread;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
@ -471,14 +471,14 @@ impl Domain for ClientDomain {
let ui = ui.clone();
async move {
let mut cloned_ui = ui.clone();
let client = join_handle_result(spawn_into_new_thread(move || match &config {
let client = spawn_into_new_thread(move || match &config {
ClientDomainConfig::Unix(unix) => {
let initial = true;
Client::new_unix_domain(domain_id, unix, initial, &mut cloned_ui)
}
ClientDomainConfig::Tls(tls) => Client::new_tls(domain_id, tls, &mut cloned_ui),
ClientDomainConfig::Ssh(ssh) => Client::new_ssh(domain_id, ssh, &mut cloned_ui),
}))
})
.await?;
ui.output_str("Checking server version\n");

View File

@ -157,7 +157,8 @@ impl Pane for ClientPane {
data,
})
.await
});
})
.detach();
self.renderable
.borrow()
.inner
@ -192,7 +193,8 @@ impl Pane for ClientPane {
zoomed,
})
.await
});
})
.detach();
inner.update_last_send();
}
@ -222,7 +224,8 @@ impl Pane for ClientPane {
size,
})
.await
});
})
.detach();
inner.update_last_send();
}
Ok(())
@ -266,7 +269,8 @@ impl Pane for ClientPane {
input_serial,
})
.await
});
})
.detach();
self.renderable
.borrow()
.inner

View File

@ -88,7 +88,8 @@ impl MouseState {
Self::next(Rc::clone(&state));
Ok::<(), anyhow::Error>(())
});
})
.detach();
true
} else {
false

View File

@ -498,7 +498,8 @@ impl RenderableInner {
})
.await;
Self::apply_lines(local_pane_id, result, to_fetch, now)
});
})
.detach();
}
fn apply_lines(
@ -597,7 +598,8 @@ impl RenderableInner {
inner.poll_in_progress.store(false, Ordering::SeqCst);
}
Ok::<(), anyhow::Error>(())
});
})
.detach();
Ok(())
}
}

View File

@ -475,12 +475,9 @@ pub async fn run<
let window_id: WindowId = promise::spawn::spawn_into_main_thread(async move {
register_tab(input_tx, render_rx, width, height).await
})
.await
.unwrap_or_else(|| bail!("task panicked or was cancelled"))?;
.await?;
let result = promise::spawn::spawn_into_new_thread(move || f(tw_term))
.await
.unwrap_or_else(|| bail!("task panicked or was cancelled"));
let result = promise::spawn::spawn_into_new_thread(move || f(tw_term)).await;
// Since we're typically called with an outstanding Activity token active,
// the dead status of the tab will be ignored until after the activity
@ -490,7 +487,8 @@ pub async fn run<
promise::spawn::spawn_into_main_thread(async move {
let mux = Mux::get().unwrap();
mux.kill_window(window_id);
});
})
.detach();
result
}

View File

@ -95,6 +95,7 @@ fn main() -> anyhow::Result<()> {
eprintln!("running this async block");
spawn_window().await.ok();
eprintln!("end of async block");
});
})
.detach();
conn.run_message_loop()
}

View File

@ -64,7 +64,8 @@ impl Connection {
let mut inner = handle.borrow_mut();
prom.result(f(&mut inner));
}
});
})
.detach();
future
}

View File

@ -129,7 +129,8 @@ impl WaylandConnection {
let mut inner = handle.borrow_mut();
prom.result(f(&mut inner));
}
});
})
.detach();
future
}

View File

@ -130,7 +130,8 @@ impl Connection {
let mut inner = handle.borrow_mut();
prom.result(f(&mut inner));
}
});
})
.detach();
future
}

View File

@ -10,6 +10,7 @@ use mio::{Evented, Events, Poll, PollOpt, Ready, Token};
use std::cell::RefCell;
use std::collections::HashMap;
use std::os::unix::io::AsRawFd;
#[cfg(feature = "opengl")]
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
@ -457,7 +458,8 @@ impl XConnection {
let mut inner = handle.lock().unwrap();
prom.result(f(&mut inner));
}
});
})
.detach();
future
}

View File

@ -43,11 +43,21 @@ impl SpawnQueue {
pub fn register_promise_schedulers(&self) {
promise::spawn::set_schedulers(
Box::new(|task| {
SPAWN_QUEUE.spawn_impl(Box::new(move || task.run()), true);
Box::new(|runnable| {
SPAWN_QUEUE.spawn_impl(
Box::new(move || {
runnable.run();
}),
true,
);
}),
Box::new(|low_pri_task| {
SPAWN_QUEUE.spawn_impl(Box::new(move || low_pri_task.run()), false);
Box::new(|runnable| {
SPAWN_QUEUE.spawn_impl(
Box::new(move || {
runnable.run();
}),
false,
);
}),
);
}