diff --git a/Cargo.lock b/Cargo.lock index ef070c29e..244fedeb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,11 +41,21 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1ba68f4276a778591e36a0c348a269888f3a177c8d2054969389e3b59611ff5" +[[package]] +name = "async-barrier" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06293698675eb72e1155867e5982f199d6b6c230dca35bc5ffd9852f470c22a" +dependencies = [ + "async-mutex", + "event-listener", +] + [[package]] name = "async-channel" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43de69555a39d52918e2bc33a408d3c0a86c829b212d898f4ca25d21a6387478" +checksum = "59386c3aa61f4e14c4ddda1a6744c119b4bf278ec9f866d3c20bc5728ee0eb97" dependencies = [ "concurrent-queue", "event-listener", @@ -54,37 +64,116 @@ dependencies = [ [[package]] name = "async-executor" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f47c78ea98277cb1f5e6f60ba4fc762f5eafe9f6511bc2f7dfd8b75c225650" +checksum = "29a9fcb167455a47928782aac31ee2752481385d305d613458db7bd4cc7ba0b4" dependencies = [ - "async-io", + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-fs" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dffe45cf37df0df9439827c77ee4a39b95f26a0121fb615f989471c283ea6f7" +dependencies = [ + "blocking", "futures-lite", - "multitask", - "parking 1.0.6", - "scoped-tls", - "waker-fn", ] [[package]] name = "async-io" -version = "0.1.11" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae22a338d28c75b53702b66f77979062cb29675db376d99e451af4fa79dedb3" +checksum = "c9424bb88867b003ca32a1d99cf64595c5a310c7322891795f38aa061860d0af" dependencies = [ "cfg-if", "concurrent-queue", + "fastrand", "futures-lite", "libc", + "log", "once_cell", - "parking 2.0.0", + "parking", "polling", "socket2", "vec-arena", + "waker-fn", "wepoll-sys-stjepang", "winapi", ] +[[package]] +name = "async-lock" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7ffacc3ef2d598b07148706964f7a9b256926d5f9531c35126e8b8bb417ac5" +dependencies = [ + "async-barrier", + "async-mutex", + "async-rwlock", + "async-semaphore", +] + +[[package]] +name = "async-mutex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065de1ccf10280d0d75c2f3a71a970ee1007c85c51aa3e7deee1df100f1dfadb" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-net" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79db11f7831e0de63763ed8e3f23c2095aad16c6ca2fffa727b922a955f026b2" +dependencies = [ + "async-io", + "blocking", + "futures-lite", +] + +[[package]] +name = "async-process" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d510baf319291a41e6c3363df4408a3b196ad18fcb1305ae4e500f2eabe260" +dependencies = [ + "async-io", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "once_cell", + "signal-hook", + "winapi", +] + +[[package]] +name = "async-rwlock" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f8978b5ae008b5177da07a1bf1bfbe428f9bdb970c3fca0e92ed1c1930d7f34" +dependencies = [ + "async-mutex", + "event-listener", +] + +[[package]] +name = "async-semaphore" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64fa45fce1280cc450781869a9edec7986cdefb971d3e1607798b5e52bad068a" +dependencies = [ + "event-listener", +] + [[package]] name = "async-task" version = "3.0.0" @@ -105,12 +194,13 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blocking" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5800d29218fea137b0880387e5948694a23c93fcdde157006966693a865c7c" +checksum = "3f30e08a950487f80d2de5cbb72772c8bbaed6002dc8d979722dabd034ede18d" dependencies = [ "async-channel", "atomic-waker", + "fastrand", "futures-lite", "once_cell", "waker-fn", @@ -178,23 +268,17 @@ dependencies = [ "winapi", ] -[[package]] -name = "easy-parallel" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd4afd79212583ff429b913ad6605242ed7eec277e950b1438f300748f948f4" - [[package]] name = "event-listener" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f14646a9e0430150a87951622ba9675472b68e384b7701b8423b30560805c7a" +checksum = "e1cd41440ae7e4734bbd42302f63eaba892afc93a3912dad84006247f0dedb0e" [[package]] name = "fastrand" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd3bdaaf0a72155260a1c098989b60db1cbb22d6a628e64f16237aa4da93cc7" +checksum = "5c85295147490b8fcf2ea3d104080a105a8b2c63f9c319e82c02d8e952388919" [[package]] name = "futf" @@ -244,15 +328,15 @@ checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" [[package]] name = "futures-lite" -version = "0.1.11" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97999970129b808f0ccba93211201d431fcc12d7e1ffae03a61b5cedd1a7ced2" +checksum = "5dfd8ccee4974dccf68838bb2b9c90439238090061c82454af83866ac059eb9f" dependencies = [ "fastrand", "futures-core", "futures-io", "memchr", - "parking 2.0.0", + "parking", "pin-project-lite", "waker-fn", ] @@ -334,6 +418,7 @@ dependencies = [ "crossterm", "futures", "helix-core", + "num_cpus", "smol", ] @@ -412,17 +497,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "multitask" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c09c35271e7dcdb5f709779111f2c8e8ab8e06c1b587c1c6a9e179d865aaa5b4" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", -] - [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -454,12 +528,6 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" -[[package]] -name = "parking" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c" - [[package]] name = "parking" version = "2.0.0" @@ -524,12 +592,13 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "polling" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e09dffb745feffca5be3dea51c02b7b368c4597ab0219a82acaf9799ab3e0d1" +checksum = "b1e9fa0ab21ed700cf0c4ebec57ae5496bec942a0aef9545562979a9f75b97aa" dependencies = [ "cfg-if", "libc", + "log", "wepoll-sys-stjepang", "winapi", ] @@ -548,9 +617,9 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" [[package]] name = "proc-macro2" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +checksum = "175c513d55719db99da20232b06cda8bab6b83ec2d04e3283edf0213c37c1a29" dependencies = [ "unicode-xid", ] @@ -579,12 +648,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" @@ -626,18 +689,20 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" [[package]] name = "smol" -version = "0.3.3" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67583f4ccc13bbb105a0752058d8ad66c47753d85445952809bcaca891954f83" +checksum = "0714120d45176fe0b7763527a28c32af32389eb5c07e28142766080839c491ed" dependencies = [ "async-channel", "async-executor", + "async-fs", "async-io", + "async-lock", + "async-net", + "async-process", "blocking", - "cfg-if", - "easy-parallel", "futures-lite", - "num_cpus", + "once_cell", ] [[package]] @@ -654,9 +719,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" +checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9" dependencies = [ "proc-macro2", "quote", @@ -666,7 +731,7 @@ dependencies = [ [[package]] name = "tendril" version = "0.4.1" -source = "git+https://github.com/servo/tendril#e379f8547241d84865aa45f44802feeff1126726" +source = "git+https://github.com/servo/tendril#9532724c32a0bf5e65acb56209373d97223bc530" dependencies = [ "futf", "mac", @@ -699,15 +764,15 @@ checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] name = "vec-arena" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17dfb54bf57c9043f4616cb03dab30eff012cc26631b797d8354b916708db919" +checksum = "8cb18268690309760d59ee1a9b21132c126ba384f374c59a94db4bc03adeb561" [[package]] name = "waker-fn" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9571542c2ce85ce642e6b58b3364da2fb53526360dfb7c211add4f5c23105ff7" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "wepoll-sys-stjepang" diff --git a/editor.rs b/editor.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 1cb2c3bca..32e72825d 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -19,9 +19,9 @@ argh = "0.1.3" helix-core = { path = "../helix-core" } crossterm = { version = "0.17.7", features = ["event-stream"] } -smol = "0.3" +smol = "0.4" futures = { version = "0.3.5", default-features = false, features = ["std", "async-await"] } +num_cpus = "1.13.0" # futures-timer = "3.0.2" -# async-channel = "1.4.0" # tui = { version = "0.9.5", default-features = false } diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs index a83db6fa9..bddc28590 100644 --- a/helix-term/src/editor.rs +++ b/helix-term/src/editor.rs @@ -39,6 +39,8 @@ impl BufferComponent<'_> { } } +static EX: smol::Executor = smol::Executor::new(); + pub struct Editor { state: Option, first_line: u16, @@ -134,14 +136,14 @@ impl Editor { } } - pub fn run(&mut self) -> Result<(), Error> { + pub async fn run(&mut self) -> Result<(), Error> { enable_raw_mode()?; let mut stdout = stdout(); execute!(stdout, terminal::EnterAlternateScreen)?; - smol::run(self.print_events()); + self.print_events().await; execute!(stdout, terminal::LeaveAlternateScreen)?; diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 6e5ec5ffe..7a9289eea 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -18,12 +18,19 @@ pub struct Args { files: Vec, } +static EX: smol::Executor = smol::Executor::new(); + fn main() -> Result<(), Error> { let args: Args = argh::from_env(); println!("{:?}", args.files); - let mut editor = editor::Editor::new(args)?; - editor.run(); + for _ in 0..num_cpus::get() { + std::thread::spawn(move || smol::block_on(EX.run(smol::future::pending::<()>()))); + } + + smol::block_on(EX.run(async { + editor::Editor::new(args).unwrap().run().await; + })); Ok(()) }