├── README.md ├── RESULT.md ├── RESULT_old.md ├── dotnet ├── Program.cs └── dotnet.csproj ├── go ├── go.mod └── main.go ├── java └── VirtualThreads.java ├── nodejs └── main.js ├── python └── main.py ├── rust_async_std ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust_futures ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs └── rust_tokio ├── Cargo.lock ├── Cargo.toml └── src └── main.rs /README.md: -------------------------------------------------------------------------------- 1 | # async-runtimes-benchmarks 2 | 3 | This repository contains a few programs written in various programing languages. 4 | Each program spawns N concurrent tasks. The number of tasks is controlled by the 5 | command line argiment. Each tasks waits 10 seconds and finishes. The programs finish when 6 | all tasks exit. 7 | 8 | The purpose of those programs is to measure the memory footprint of concurrent tasks in 9 | different language runtimes. 10 | -------------------------------------------------------------------------------- /RESULT.md: -------------------------------------------------------------------------------- 1 | # How Much Memory Do You Need in 2024 to Run 1 Million Concurrent Tasks? - Take 2 2 | 3 | Did you still remember [the memory consumption comparison](https://pkolaczk.github.io/memory-consumption-of-async/) between asynchronous programming across popular languages in 2023? 4 | 5 | Now at the end of 2024, I wonder how things changed in the span of one year, with the latest version of languages. 6 | 7 | So I did the benchmark again in [How Much Memory Do You Need in 2024 to Run 1 Million Concurrent Tasks?](https://hez2010.github.io/async-runtimes-benchmarks-2024) 8 | 9 | Then some folks pointed out that the code for some languages were non-optimal, so after taking changes from the community, I ran the benchmark again. 10 | 11 | Now let's see the result. 12 | 13 | ## Benchmark 14 | 15 | The program to benchmark is the same with the one in the last year: 16 | 17 | > Let's launch N concurrent tasks, where each task waits for 10 seconds and then the program exists after all tasks finish. The number of tasks is controlled by the command line argument. 18 | 19 | This time, let's focus on coroutine instead of multiple threads. 20 | 21 | All benchmark code can be accessed at [async-runtimes-benchmarks-2024](https://github.com/hez2010/async-runtimes-benchmarks-2024). 22 | 23 | What is a coroutine? 24 | 25 | > Coroutines are computer program components that allow execution to be suspended and resumed, generalizing subroutines for cooperative multitasking. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes. 26 | 27 | ### Rust 28 | 29 | I created 3 programs in Rust. One uses `tokio`: 30 | 31 | ```rust 32 | use std::env; 33 | use tokio::{spawn, time::{sleep, Duration}}; 34 | 35 | #[tokio::main] 36 | async fn main() { 37 | let num_tasks = env::args().skip(1).next().unwrap().parse().unwrap(); 38 | 39 | let mut tasks = Vec::with_capacity(num_tasks); 40 | for _ in 0..num_tasks { 41 | tasks.push(spawn(sleep(Duration::from_secs(10)))); 42 | } 43 | for task in tasks { 44 | task.await.unwrap(); 45 | } 46 | } 47 | ``` 48 | 49 | One uses `async_std`: 50 | 51 | ```rust 52 | use std::env; 53 | use async_std::task; 54 | use std::time::Duration; 55 | 56 | #[async_std::main] 57 | async fn main() { 58 | let num_tasks = env::args().skip(1).next().unwrap().parse().unwrap(); 59 | 60 | let mut tasks = Vec::with_capacity(num_tasks); 61 | for _ in 0..num_tasks { 62 | tasks.push(task::spawn(task::sleep(Duration::from_secs(10)))); 63 | } 64 | 65 | for task in tasks { 66 | task.await; 67 | } 68 | } 69 | ``` 70 | 71 | And one uses `tokio` but uses `futures::future::join_all` to track all tasks instead of `spawn` each task separately: 72 | 73 | ```rust 74 | use std::env; 75 | use std::time::Duration; 76 | 77 | #[tokio::main] 78 | async fn main() { 79 | let num_tasks = env::args().skip(1).next().unwrap().parse().unwrap(); 80 | 81 | futures::future::join_all((0..num_tasks).map(|_| tokio::time::sleep(Duration::from_secs(10)))) 82 | .await; 83 | } 84 | ``` 85 | 86 | Both `tokio` and `async_std` are popular async runtime commonly used in Rust. 87 | 88 | ### C# 89 | 90 | C#, similar to Rust, has first-class support for async/await: 91 | 92 | ```csharp 93 | int numTasks = int.Parse(args[0]); 94 | 95 | List tasks = new List(numTasks); 96 | 97 | for (int i = 0; i < numTasks; i++) 98 | { 99 | tasks.Add(Task.Delay(TimeSpan.FromSeconds(10))); 100 | } 101 | 102 | await Task.WhenAll(tasks); 103 | ``` 104 | 105 | .NET also offers NativeAOT compilation since .NET 7, which compiles the code to the final binary directly so that it no longer needs a VM to run managed code. So we added the benchmark for NativeAOT as well. 106 | 107 | ### NodeJS 108 | 109 | So does NodeJS: 110 | 111 | ```javascript 112 | const util = require('util'); 113 | const delay = util.promisify(setTimeout); 114 | 115 | async function runTasks(numTasks) { 116 | const tasks = []; 117 | 118 | for (let i = 0; i < numTasks; i++) { 119 | tasks.push(delay(10000)); 120 | } 121 | 122 | await Promise.all(tasks); 123 | } 124 | 125 | const numTasks = parseInt(process.argv[2]); 126 | runTasks(numTasks); 127 | ``` 128 | 129 | ### Python 130 | 131 | And Python, too: 132 | 133 | ```python 134 | import asyncio 135 | import sys 136 | 137 | async def main(num_tasks): 138 | tasks = [] 139 | 140 | for task_id in range(num_tasks): 141 | tasks.append(asyncio.sleep(10)) 142 | 143 | await asyncio.gather(*tasks) 144 | 145 | if __name__ == "__main__": 146 | num_tasks = int(sys.argv[1]) 147 | asyncio.run(main(num_tasks)) 148 | ``` 149 | 150 | 151 | ### Go 152 | 153 | In Go, goroutines are the building block for concurrency. We don’t await them separately, but we use a `WaitGroup` instead: 154 | 155 | ```go 156 | package main 157 | 158 | import ( 159 | "fmt" 160 | "os" 161 | "strconv" 162 | "sync" 163 | "time" 164 | ) 165 | 166 | func main() { 167 | numRoutines := 100000 168 | if len(os.Args) > 1 { 169 | n, err := strconv.Atoi(os.Args[1]) 170 | if err == nil { 171 | numRoutines = n 172 | } 173 | } 174 | 175 | var wg sync.WaitGroup 176 | for i := 0; i < numRoutines; i++ { 177 | wg.Add(1) 178 | go func() { 179 | time.Sleep(10 * time.Second) 180 | wg.Done() 181 | }() 182 | } 183 | wg.Wait() 184 | } 185 | ``` 186 | 187 | ### Java 188 | 189 | Java offers virtual threads since JDK 21, which are a similar concept to goroutines: 190 | 191 | ```java 192 | import java.time.Duration; 193 | import java.util.ArrayList; 194 | import java.util.List; 195 | 196 | public class VirtualThreads { 197 | 198 | public static void main(String[] args) throws InterruptedException { 199 | int numTasks = Integer.parseInt(args[0]); 200 | List threads = new ArrayList<>(numTasks); 201 | 202 | for (int i = 0; i < numTasks; i++) { 203 | Thread thread = Thread.startVirtualThread(() -> { 204 | try { 205 | Thread.sleep(Duration.ofSeconds(10)); 206 | } catch (InterruptedException e) { 207 | // Handle exception 208 | } 209 | }); 210 | threads.add(thread); 211 | } 212 | 213 | for (Thread thread : threads) { 214 | thread.join(); 215 | } 216 | } 217 | } 218 | ``` 219 | 220 | While there's a new variant of JVM called GraalVM. GraalVM also offers native image, which is a similar concept to NativeAOT in .NET. So we added the benchmark for GraalVM as well. 221 | 222 | ## Test Environment 223 | 224 | - Hardware: 13th Gen Intel(R) Core(TM) i7-13700K 225 | - OS: Debian GNU/Linux 12 (bookworm) 226 | - Rust: 1.82.0 227 | - .NET: 9.0.100 228 | - Go: 1.23.3 229 | - Java: openjdk 23.0.1 build 23.0.1+11-39 230 | - Java (GraalVM): java 23.0.1 build 23.0.1+11-jvmci-b01 231 | - NodeJS: v23.2.0 232 | - Python: 3.13.0 233 | 234 | All programs were launched using the release mode if available, and support for internationalization and globalization was disabled as we did't have libicu in our test environment. 235 | 236 | ## Results 237 | 238 | 241 | 242 | ### Minimum Footprint 243 | 244 | Let's start from something small, because some runtimes require some memory for themselves, let's first launch only one task. 245 | 246 |
247 | 248 | 249 |
250 | 265 | 266 | **Note: You can click the legend label on the top to hide a specific legend.** 267 | 268 | We can see that Rust, C# (NativeAOT), and Go achieved similar results, as they were compiled statically to native binaries and needed very little memory. Java (GraalVM native-image) also did a great job but cost a bit more than the other statically compiled ones. The other programs running on managed platforms or through interpreters consume more memory. 269 | 270 | Rust (futures) seems to have the smallest footprint in this case. While Go and C# (NativeAOT) seem to have the similar minimal footprint. 271 | 272 | Python, which is running on an interpreter, also shows great result. 273 | 274 | Java with GraalVM is a bit surprising, as it cost far more memory than Java with OpenJDK, but I guess this can be tuned with some settings. 275 | 276 | ### 10K Tasks 277 | 278 |
279 | 280 | 281 |
282 | 297 | 298 | A few surprises here! The three Rust benchmarks, C# (NativeAOT) achieved very promising results: they both used very little memory (less than 10MB), which didn't grow too much compared to minimal footprint results, even though there were 10K tasks running behind the scenes! C# (NativeAOT) followed closely behind, using only ~10MB of memory. We need more tasks to put more pressure on them! 299 | 300 | The memory consumption grew dramatically in Go. Goroutines are supposed to be very lightweight, but they actually consumed far more RAM than Rust required. In this case, virtual threads in Java (GraalVM native image) seem to be more lightweight than Goroutines in Go. To my surprise, both Go and Java (GraalVM native image), which were compiled to native binaries statically, cost similar RAM with the C# one running on a VM! 301 | 302 | ### 100K Tasks 303 | 304 |
305 | 306 | 307 |
308 | 323 | 324 | After we increased the number of tasks to 100K, the memory consumption of all the languages started to grow significantly. 325 | 326 | Both Rust and C# did a really good job in this case. Rust continues to lead the benchmark, and C# follows closely. Really impressive! 327 | 328 | At this point, the Go program has been beaten not only by Rust but also by Java (except the one running on GraalVM), C#, and NodeJS. But worth to note that Java costs significantly more CPU to complete the benchmark. 329 | 330 | ### 1 Million Tasks 331 | 332 | Let's go extreme now. 333 | 334 |
335 | 336 | 337 |
338 | 353 | 354 | Finally, Rust (futures) and C# show very promising result; either is very competitive and has really become a monster. 355 | 356 | And it's worth to note that Rust consistently cost the least CPU for running all the tasks. 357 | 358 | NodeJS, which runs on a VM, also shows great result in this case: although it costs more RAM than C#, it requires less CPU to complete the benchmark, which is even less than some of the Rust benchmarks. 359 | 360 | While both Java and Python start to be not able to complete the benchmark in 10 seconds, and Java costs significant more CPU than other languages. 361 | 362 | ## Final Word 363 | 364 | As we have observed, a high number of concurrent tasks can consume a significant amount of memory, even if they do not perform complex operations. Different language runtimes have varying trade-offs, with some being lightweight and efficient for a small number of tasks but scaling poorly with hundreds of thousands of tasks. 365 | 366 | Many things have changed since last year. With the benchmark results on the latest compilers and runtimes, we see a huge improvement in .NET, and .NET with NativeAOT is really competitive. 367 | 368 | Rust continues to be memory saving as expected, and achieved similar result with C# (NativeAOT). 369 | 370 | NodeJS shows impressive result in term of CPU usage. 371 | 372 | Python faced performance issue and was not able to complete the benchmark in time in the 1M case. 373 | 374 | Both Java Virtual Thread and Goroutine take similar approach on concurrency, while others are using async/await, so let's exclude other languages and only focus on these two: the native image of Java built with GraalVM did a great job in terms of memory efficiency, but it failed to finished the benchmark in 10 seconds in the 1M case; while Goroutine is able to complete all the tasks in time, but it costs much more RAM than Java in the 1M case. 375 | -------------------------------------------------------------------------------- /RESULT_old.md: -------------------------------------------------------------------------------- 1 | # How Much Memory Do You Need in 2024 to Run 1 Million Concurrent Tasks? 2 | 3 | ## A take 2 on this benchmark 4 | 5 | **Please refer to [How Much Memory Do You Need in 2024 to Run 1 Million Concurrent Tasks? - Take 2](https://hez2010.github.io/async-runtimes-benchmarks-2024/take2.html) to check the latest result.** 6 | 7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 17 | ---- 18 | 19 | # Old post 20 | 21 | Did you still remember [the memory consumption comparison](https://pkolaczk.github.io/memory-consumption-of-async/) between asynchronous programming across popular languages in 2023? 22 | 23 | Now at the end of 2024, I wonder how things changed in the span of one year, with the latest version of languages. 24 | 25 | Let's do the benchmark again and see the results! 26 | 27 | ## Benchmark 28 | 29 | The program to benchmark is the same with the one in the last year: 30 | 31 | > Let's launch N concurrent tasks, where each task waits for 10 seconds and then the program exists after all tasks finish. The number of tasks is controlled by the command line argument. 32 | 33 | This time, let's focus on coroutine instead of multiple threads. 34 | 35 | All benchmark code can be accessed at [async-runtimes-benchmarks-2024](https://github.com/hez2010/async-runtimes-benchmarks-2024). 36 | 37 | What is a coroutine? 38 | 39 | > Coroutines are computer program components that allow execution to be suspended and resumed, generalizing subroutines for cooperative multitasking. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes. 40 | 41 | ### Rust 42 | 43 | I created 2 programs in Rust. One uses `tokio`: 44 | 45 | ```rust 46 | use std::env; 47 | use tokio::time::{sleep, Duration}; 48 | 49 | #[tokio::main] 50 | async fn main() { 51 | let args: Vec = env::args().collect(); 52 | let num_tasks = args[1].parse::().unwrap(); 53 | let mut tasks = Vec::new(); 54 | for _ in 0..num_tasks { 55 | tasks.push(sleep(Duration::from_secs(10))); 56 | } 57 | futures::future::join_all(tasks).await; 58 | } 59 | ``` 60 | 61 | while another one uses `async_std`: 62 | 63 | ```rust 64 | use std::env; 65 | use async_std::task; 66 | use futures::future::join_all; 67 | use std::time::Duration; 68 | 69 | #[async_std::main] 70 | async fn main() { 71 | let args: Vec = env::args().collect(); 72 | let num_tasks = args[1].parse::().unwrap(); 73 | 74 | let mut tasks = Vec::new(); 75 | for _ in 0..num_tasks { 76 | tasks.push(task::sleep(Duration::from_secs(10))); 77 | } 78 | 79 | join_all(tasks).await; 80 | } 81 | ``` 82 | 83 | Both are popular async runtime commonly used in Rust. 84 | 85 | ### C# 86 | 87 | C#, similar to Rust, has first-class support for async/await: 88 | 89 | ```csharp 90 | int numTasks = int.Parse(args[0]); 91 | List tasks = new List(); 92 | 93 | for (int i = 0; i < numTasks; i++) 94 | { 95 | tasks.Add(Task.Delay(TimeSpan.FromSeconds(10))); 96 | } 97 | 98 | await Task.WhenAll(tasks); 99 | ``` 100 | 101 | .NET also offers NativeAOT compilation since .NET 7, which compiles the code to the final binary directly so that it no longer needs a VM to run managed code. So we added the benchmark for NativeAOT as well. 102 | 103 | ### NodeJS 104 | 105 | So does NodeJS: 106 | 107 | ```javascript 108 | const util = require('util'); 109 | const delay = util.promisify(setTimeout); 110 | 111 | async function runTasks(numTasks) { 112 | const tasks = []; 113 | 114 | for (let i = 0; i < numTasks; i++) { 115 | tasks.push(delay(10000)); 116 | } 117 | 118 | await Promise.all(tasks); 119 | } 120 | 121 | const numTasks = parseInt(process.argv[2]); 122 | runTasks(numTasks); 123 | ``` 124 | 125 | ### Python 126 | 127 | And Python, too: 128 | 129 | ```python 130 | import asyncio 131 | import sys 132 | 133 | async def main(num_tasks): 134 | tasks = [] 135 | 136 | for task_id in range(num_tasks): 137 | tasks.append(asyncio.sleep(10)) 138 | 139 | await asyncio.gather(*tasks) 140 | 141 | if __name__ == "__main__": 142 | num_tasks = int(sys.argv[1]) 143 | asyncio.run(main(num_tasks)) 144 | ``` 145 | 146 | 147 | ### Go 148 | 149 | In Go, goroutines are the building block for concurrency. We don’t await them separately, but we use a `WaitGroup` instead: 150 | 151 | ```go 152 | package main 153 | 154 | import ( 155 | "fmt" 156 | "os" 157 | "strconv" 158 | "sync" 159 | "time" 160 | ) 161 | 162 | func main() { 163 | numRoutines, _ := strconv.Atoi(os.Args[1]) 164 | var wg sync.WaitGroup 165 | for i := 0; i < numRoutines; i++ { 166 | wg.Add(1) 167 | go func() { 168 | defer wg.Done() 169 | time.Sleep(10 * time.Second) 170 | }() 171 | } 172 | wg.Wait() 173 | } 174 | ``` 175 | 176 | ### Java 177 | 178 | Java offers virtual threads since JDK 21, which are a similar concept to goroutines: 179 | 180 | ```java 181 | import java.time.Duration; 182 | import java.util.ArrayList; 183 | import java.util.List; 184 | 185 | public class VirtualThreads { 186 | 187 | public static void main(String[] args) throws InterruptedException { 188 | int numTasks = Integer.parseInt(args[0]); 189 | List threads = new ArrayList<>(); 190 | 191 | for (int i = 0; i < numTasks; i++) { 192 | Thread thread = Thread.startVirtualThread(() -> { 193 | try { 194 | Thread.sleep(Duration.ofSeconds(10)); 195 | } catch (InterruptedException e) { 196 | // Handle exception 197 | } 198 | }); 199 | threads.add(thread); 200 | } 201 | 202 | for (Thread thread : threads) { 203 | thread.join(); 204 | } 205 | } 206 | } 207 | ``` 208 | 209 | While there's a new variant of JVM called GraalVM. GraalVM also offers native image, which is a similar concept to NativeAOT in .NET. So we added the benchmark for GraalVM as well. 210 | 211 | ## Test Environment 212 | 213 | - Hardware: 13th Gen Intel(R) Core(TM) i7-13700K 214 | - OS: Debian GNU/Linux 12 (bookworm) 215 | - Rust: 1.82.0 216 | - .NET: 9.0.100 217 | - Go: 1.23.3 218 | - Java: openjdk 23.0.1 build 23.0.1+11-39 219 | - Java (GraalVM): java 23.0.1 build 23.0.1+11-jvmci-b01 220 | - NodeJS: v23.2.0 221 | - Python: 3.13.0 222 | 223 | All programs were launched using the release mode if available, and support for internationalization and globalization was disabled as we did't have libicu in our test environment. 224 | 225 | ## Results 226 | 227 | 230 | 231 | ### Minimum Footprint 232 | 233 | Let's start from something small, because some runtimes require some memory for themselves, let's first launch only one task. 234 | 235 |
236 | 237 | 238 |
239 | 240 | 258 | 259 | We can see that Rust, C# (NativeAOT), and Go achieved similar results, as they were compiled statically to native binaries and needed very little memory. Java (GraalVM native-image) also did a great job but cost a bit more than the other statically compiled ones. The other programs running on managed platforms or through interpreters consume more memory. 260 | 261 | Go seems to have the smallest footprint in this case. 262 | 263 | Java with GraalVM is a bit surprising, as it cost far more memory than Java with OpenJDK, but I guess this can be tuned with some settings. 264 | 265 | ### 10K Tasks 266 | 267 |
268 | 269 | 270 |
271 | 272 | 290 | A few surprises here! The two Rust benchmarks achieved very promising results: they both used very little memory, which didn't grow too much compared to minimal footprint results, even though there were 10K tasks running behind the scenes! C# (NativeAOT) followed closely behind, using only ~10MB of memory. We need more tasks to put more pressure on them! 291 | 292 | The memory consumption grew dramatically in Go. Goroutines are supposed to be very lightweight, but they actually consumed far more RAM than Rust required. In this case, virtual threads in Java (GraalVM native image) seem to be more lightweight than Goroutines in Go. To my surprise, both Go and Java (GraalVM native image), which were compiled to native binaries statically, cost more RAM than the C# one running on a VM! 293 | 294 | ### 100K Tasks 295 | 296 |
297 | 298 | 299 |
300 | 301 | 319 | 320 | After we increased the number of tasks to 100K, the memory consumption of all the languages started to grow significantly. 321 | 322 | Both Rust and C# did a really good job in this case. A big surprise is that C# (NativeAOT) even cost less RAM than Rust and beat all other languages. Really impressive! 323 | 324 | At this point, the Go program has been beaten not only by Rust but also by Java (except the one running on GraalVM), C#, and NodeJS. 325 | 326 | ### 1 Million Tasks 327 | 328 | Let's go extreme now. 329 | 330 |
331 | 332 | 333 |
334 | 335 | 353 | 354 | Finally, C# undoubtedly beat all other languages; it's very competitive and has really become a monster. And as expected, Rust continues to do a good job on memory efficiency. 355 | 356 | The distance between Go and the others increased. Now Go loses by over 13 times to the winner. It also loses by over 2 times to Java, which contradicts the general perception of the JVM being a memory hog and Go being lightweight. 357 | 358 | ## Final Word 359 | 360 | As we have observed, a high number of concurrent tasks can consume a significant amount of memory, even if they do not perform complex operations. Different language runtimes have varying trade-offs, with some being lightweight and efficient for a small number of tasks but scaling poorly with hundreds of thousands of tasks. 361 | 362 | Many things have changed since last year. With the benchmark results on the latest compilers and runtimes, we see a huge improvement in .NET, and .NET with NativeAOT is really competitive with Rust. The native image of Java built with GraalVM also did a great job in terms of memory efficiency. However, goroutines continue to be inefficient in resource consumption. 363 | -------------------------------------------------------------------------------- /dotnet/Program.cs: -------------------------------------------------------------------------------- 1 | int numTasks = int.Parse(args[0]); 2 | 3 | List tasks = new List(numTasks); 4 | 5 | for (int i = 0; i < numTasks; i++) 6 | { 7 | tasks.Add(Task.Delay(TimeSpan.FromSeconds(10))); 8 | } 9 | 10 | await Task.WhenAll(tasks); 11 | -------------------------------------------------------------------------------- /dotnet/dotnet.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /go/go.mod: -------------------------------------------------------------------------------- 1 | module coroutines 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | "sync" 8 | "time" 9 | ) 10 | 11 | func main() { 12 | numRoutines := 100000 13 | if len(os.Args) > 1 { 14 | n, err := strconv.Atoi(os.Args[1]) 15 | if err == nil { 16 | numRoutines = n 17 | } 18 | } 19 | 20 | var wg sync.WaitGroup 21 | for i := 0; i < numRoutines; i++ { 22 | wg.Add(1) 23 | go func() { 24 | time.Sleep(10 * time.Second) 25 | wg.Done() 26 | }() 27 | } 28 | wg.Wait() 29 | } 30 | -------------------------------------------------------------------------------- /java/VirtualThreads.java: -------------------------------------------------------------------------------- 1 | import java.time.Duration; 2 | import java.util.ArrayList; 3 | import java.util.List; 4 | 5 | public class VirtualThreads { 6 | 7 | public static void main(String[] args) throws InterruptedException { 8 | int numTasks = Integer.parseInt(args[0]); 9 | List threads = new ArrayList<>(numTasks); 10 | 11 | for (int i = 0; i < numTasks; i++) { 12 | Thread thread = Thread.startVirtualThread(() -> { 13 | try { 14 | Thread.sleep(Duration.ofSeconds(10)); 15 | } catch (InterruptedException e) { 16 | // Handle exception 17 | } 18 | }); 19 | threads.add(thread); 20 | } 21 | 22 | // Wait for all threads to complete 23 | for (Thread thread : threads) { 24 | thread.join(); 25 | } 26 | 27 | System.out.println("All fibers complete"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /nodejs/main.js: -------------------------------------------------------------------------------- 1 | const util = require('util'); 2 | const delay = util.promisify(setTimeout); 3 | 4 | async function runTasks(numTasks) { 5 | const tasks = []; 6 | 7 | for (let i = 0; i < numTasks; i++) { 8 | tasks.push(delay(10000)); 9 | } 10 | 11 | await Promise.all(tasks); 12 | } 13 | 14 | const numTasks = parseInt(process.argv[2]); 15 | runTasks(numTasks); -------------------------------------------------------------------------------- /python/main.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import sys 3 | 4 | # async def perform_task(): 5 | # await asyncio.sleep(10) 6 | 7 | 8 | async def main(num_tasks): 9 | tasks = [] 10 | 11 | for task_id in range(num_tasks): 12 | # task = asyncio.create_task(perform_task()) 13 | tasks.append(asyncio.sleep(10)) 14 | 15 | await asyncio.gather(*tasks) 16 | 17 | if __name__ == "__main__": 18 | if len(sys.argv) > 1: 19 | num_tasks = int(sys.argv[1]) 20 | else: 21 | num_tasks = 100000 22 | 23 | asyncio.run(main(num_tasks)) 24 | print("All tasks completed") 25 | 26 | -------------------------------------------------------------------------------- /rust_async_std/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "async-attributes" 7 | version = "1.1.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" 10 | dependencies = [ 11 | "quote", 12 | "syn 1.0.109", 13 | ] 14 | 15 | [[package]] 16 | name = "async-channel" 17 | version = "1.9.0" 18 | source = "registry+https://github.com/rust-lang/crates.io-index" 19 | checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" 20 | dependencies = [ 21 | "concurrent-queue", 22 | "event-listener 2.5.3", 23 | "futures-core", 24 | ] 25 | 26 | [[package]] 27 | name = "async-channel" 28 | version = "2.3.1" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" 31 | dependencies = [ 32 | "concurrent-queue", 33 | "event-listener-strategy", 34 | "futures-core", 35 | "pin-project-lite", 36 | ] 37 | 38 | [[package]] 39 | name = "async-executor" 40 | version = "1.13.1" 41 | source = "registry+https://github.com/rust-lang/crates.io-index" 42 | checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" 43 | dependencies = [ 44 | "async-task", 45 | "concurrent-queue", 46 | "fastrand", 47 | "futures-lite", 48 | "slab", 49 | ] 50 | 51 | [[package]] 52 | name = "async-global-executor" 53 | version = "2.4.1" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" 56 | dependencies = [ 57 | "async-channel 2.3.1", 58 | "async-executor", 59 | "async-io", 60 | "async-lock", 61 | "blocking", 62 | "futures-lite", 63 | "once_cell", 64 | ] 65 | 66 | [[package]] 67 | name = "async-io" 68 | version = "2.4.0" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" 71 | dependencies = [ 72 | "async-lock", 73 | "cfg-if", 74 | "concurrent-queue", 75 | "futures-io", 76 | "futures-lite", 77 | "parking", 78 | "polling", 79 | "rustix", 80 | "slab", 81 | "tracing", 82 | "windows-sys 0.59.0", 83 | ] 84 | 85 | [[package]] 86 | name = "async-lock" 87 | version = "3.4.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" 90 | dependencies = [ 91 | "event-listener 5.3.1", 92 | "event-listener-strategy", 93 | "pin-project-lite", 94 | ] 95 | 96 | [[package]] 97 | name = "async-std" 98 | version = "1.13.0" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "c634475f29802fde2b8f0b505b1bd00dfe4df7d4a000f0b36f7671197d5c3615" 101 | dependencies = [ 102 | "async-attributes", 103 | "async-channel 1.9.0", 104 | "async-global-executor", 105 | "async-io", 106 | "async-lock", 107 | "crossbeam-utils", 108 | "futures-channel", 109 | "futures-core", 110 | "futures-io", 111 | "futures-lite", 112 | "gloo-timers", 113 | "kv-log-macro", 114 | "log", 115 | "memchr", 116 | "once_cell", 117 | "pin-project-lite", 118 | "pin-utils", 119 | "slab", 120 | "wasm-bindgen-futures", 121 | ] 122 | 123 | [[package]] 124 | name = "async-task" 125 | version = "4.7.1" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" 128 | 129 | [[package]] 130 | name = "atomic-waker" 131 | version = "1.1.2" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" 134 | 135 | [[package]] 136 | name = "autocfg" 137 | version = "1.4.0" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 140 | 141 | [[package]] 142 | name = "bitflags" 143 | version = "2.6.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 146 | 147 | [[package]] 148 | name = "blocking" 149 | version = "1.6.1" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" 152 | dependencies = [ 153 | "async-channel 2.3.1", 154 | "async-task", 155 | "futures-io", 156 | "futures-lite", 157 | "piper", 158 | ] 159 | 160 | [[package]] 161 | name = "bumpalo" 162 | version = "3.16.0" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" 165 | 166 | [[package]] 167 | name = "cfg-if" 168 | version = "1.0.0" 169 | source = "registry+https://github.com/rust-lang/crates.io-index" 170 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 171 | 172 | [[package]] 173 | name = "concurrent-queue" 174 | version = "2.5.0" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" 177 | dependencies = [ 178 | "crossbeam-utils", 179 | ] 180 | 181 | [[package]] 182 | name = "crossbeam-utils" 183 | version = "0.8.20" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" 186 | 187 | [[package]] 188 | name = "errno" 189 | version = "0.3.9" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" 192 | dependencies = [ 193 | "libc", 194 | "windows-sys 0.52.0", 195 | ] 196 | 197 | [[package]] 198 | name = "event-listener" 199 | version = "2.5.3" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" 202 | 203 | [[package]] 204 | name = "event-listener" 205 | version = "5.3.1" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" 208 | dependencies = [ 209 | "concurrent-queue", 210 | "parking", 211 | "pin-project-lite", 212 | ] 213 | 214 | [[package]] 215 | name = "event-listener-strategy" 216 | version = "0.5.2" 217 | source = "registry+https://github.com/rust-lang/crates.io-index" 218 | checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" 219 | dependencies = [ 220 | "event-listener 5.3.1", 221 | "pin-project-lite", 222 | ] 223 | 224 | [[package]] 225 | name = "fastrand" 226 | version = "2.2.0" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" 229 | 230 | [[package]] 231 | name = "futures-channel" 232 | version = "0.3.31" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" 235 | dependencies = [ 236 | "futures-core", 237 | ] 238 | 239 | [[package]] 240 | name = "futures-core" 241 | version = "0.3.31" 242 | source = "registry+https://github.com/rust-lang/crates.io-index" 243 | checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" 244 | 245 | [[package]] 246 | name = "futures-io" 247 | version = "0.3.31" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" 250 | 251 | [[package]] 252 | name = "futures-lite" 253 | version = "2.5.0" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" 256 | dependencies = [ 257 | "fastrand", 258 | "futures-core", 259 | "futures-io", 260 | "parking", 261 | "pin-project-lite", 262 | ] 263 | 264 | [[package]] 265 | name = "gloo-timers" 266 | version = "0.3.0" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" 269 | dependencies = [ 270 | "futures-channel", 271 | "futures-core", 272 | "js-sys", 273 | "wasm-bindgen", 274 | ] 275 | 276 | [[package]] 277 | name = "hermit-abi" 278 | version = "0.4.0" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" 281 | 282 | [[package]] 283 | name = "js-sys" 284 | version = "0.3.72" 285 | source = "registry+https://github.com/rust-lang/crates.io-index" 286 | checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" 287 | dependencies = [ 288 | "wasm-bindgen", 289 | ] 290 | 291 | [[package]] 292 | name = "kv-log-macro" 293 | version = "1.0.7" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" 296 | dependencies = [ 297 | "log", 298 | ] 299 | 300 | [[package]] 301 | name = "libc" 302 | version = "0.2.166" 303 | source = "registry+https://github.com/rust-lang/crates.io-index" 304 | checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" 305 | 306 | [[package]] 307 | name = "linux-raw-sys" 308 | version = "0.4.14" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" 311 | 312 | [[package]] 313 | name = "log" 314 | version = "0.4.22" 315 | source = "registry+https://github.com/rust-lang/crates.io-index" 316 | checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" 317 | dependencies = [ 318 | "value-bag", 319 | ] 320 | 321 | [[package]] 322 | name = "memchr" 323 | version = "2.7.4" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 326 | 327 | [[package]] 328 | name = "once_cell" 329 | version = "1.20.2" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" 332 | 333 | [[package]] 334 | name = "parking" 335 | version = "2.2.1" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" 338 | 339 | [[package]] 340 | name = "pin-project-lite" 341 | version = "0.2.15" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" 344 | 345 | [[package]] 346 | name = "pin-utils" 347 | version = "0.1.0" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 350 | 351 | [[package]] 352 | name = "piper" 353 | version = "0.2.4" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" 356 | dependencies = [ 357 | "atomic-waker", 358 | "fastrand", 359 | "futures-io", 360 | ] 361 | 362 | [[package]] 363 | name = "polling" 364 | version = "3.7.4" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" 367 | dependencies = [ 368 | "cfg-if", 369 | "concurrent-queue", 370 | "hermit-abi", 371 | "pin-project-lite", 372 | "rustix", 373 | "tracing", 374 | "windows-sys 0.59.0", 375 | ] 376 | 377 | [[package]] 378 | name = "proc-macro2" 379 | version = "1.0.92" 380 | source = "registry+https://github.com/rust-lang/crates.io-index" 381 | checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" 382 | dependencies = [ 383 | "unicode-ident", 384 | ] 385 | 386 | [[package]] 387 | name = "quote" 388 | version = "1.0.37" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" 391 | dependencies = [ 392 | "proc-macro2", 393 | ] 394 | 395 | [[package]] 396 | name = "rust_async_std" 397 | version = "0.1.0" 398 | dependencies = [ 399 | "async-std", 400 | ] 401 | 402 | [[package]] 403 | name = "rustix" 404 | version = "0.38.41" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" 407 | dependencies = [ 408 | "bitflags", 409 | "errno", 410 | "libc", 411 | "linux-raw-sys", 412 | "windows-sys 0.52.0", 413 | ] 414 | 415 | [[package]] 416 | name = "slab" 417 | version = "0.4.9" 418 | source = "registry+https://github.com/rust-lang/crates.io-index" 419 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 420 | dependencies = [ 421 | "autocfg", 422 | ] 423 | 424 | [[package]] 425 | name = "syn" 426 | version = "1.0.109" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 429 | dependencies = [ 430 | "proc-macro2", 431 | "quote", 432 | "unicode-ident", 433 | ] 434 | 435 | [[package]] 436 | name = "syn" 437 | version = "2.0.89" 438 | source = "registry+https://github.com/rust-lang/crates.io-index" 439 | checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" 440 | dependencies = [ 441 | "proc-macro2", 442 | "quote", 443 | "unicode-ident", 444 | ] 445 | 446 | [[package]] 447 | name = "tracing" 448 | version = "0.1.41" 449 | source = "registry+https://github.com/rust-lang/crates.io-index" 450 | checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" 451 | dependencies = [ 452 | "pin-project-lite", 453 | "tracing-core", 454 | ] 455 | 456 | [[package]] 457 | name = "tracing-core" 458 | version = "0.1.33" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" 461 | 462 | [[package]] 463 | name = "unicode-ident" 464 | version = "1.0.14" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" 467 | 468 | [[package]] 469 | name = "value-bag" 470 | version = "1.10.0" 471 | source = "registry+https://github.com/rust-lang/crates.io-index" 472 | checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" 473 | 474 | [[package]] 475 | name = "wasm-bindgen" 476 | version = "0.2.95" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" 479 | dependencies = [ 480 | "cfg-if", 481 | "once_cell", 482 | "wasm-bindgen-macro", 483 | ] 484 | 485 | [[package]] 486 | name = "wasm-bindgen-backend" 487 | version = "0.2.95" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" 490 | dependencies = [ 491 | "bumpalo", 492 | "log", 493 | "once_cell", 494 | "proc-macro2", 495 | "quote", 496 | "syn 2.0.89", 497 | "wasm-bindgen-shared", 498 | ] 499 | 500 | [[package]] 501 | name = "wasm-bindgen-futures" 502 | version = "0.4.45" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" 505 | dependencies = [ 506 | "cfg-if", 507 | "js-sys", 508 | "wasm-bindgen", 509 | "web-sys", 510 | ] 511 | 512 | [[package]] 513 | name = "wasm-bindgen-macro" 514 | version = "0.2.95" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" 517 | dependencies = [ 518 | "quote", 519 | "wasm-bindgen-macro-support", 520 | ] 521 | 522 | [[package]] 523 | name = "wasm-bindgen-macro-support" 524 | version = "0.2.95" 525 | source = "registry+https://github.com/rust-lang/crates.io-index" 526 | checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" 527 | dependencies = [ 528 | "proc-macro2", 529 | "quote", 530 | "syn 2.0.89", 531 | "wasm-bindgen-backend", 532 | "wasm-bindgen-shared", 533 | ] 534 | 535 | [[package]] 536 | name = "wasm-bindgen-shared" 537 | version = "0.2.95" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" 540 | 541 | [[package]] 542 | name = "web-sys" 543 | version = "0.3.72" 544 | source = "registry+https://github.com/rust-lang/crates.io-index" 545 | checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" 546 | dependencies = [ 547 | "js-sys", 548 | "wasm-bindgen", 549 | ] 550 | 551 | [[package]] 552 | name = "windows-sys" 553 | version = "0.52.0" 554 | source = "registry+https://github.com/rust-lang/crates.io-index" 555 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 556 | dependencies = [ 557 | "windows-targets", 558 | ] 559 | 560 | [[package]] 561 | name = "windows-sys" 562 | version = "0.59.0" 563 | source = "registry+https://github.com/rust-lang/crates.io-index" 564 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 565 | dependencies = [ 566 | "windows-targets", 567 | ] 568 | 569 | [[package]] 570 | name = "windows-targets" 571 | version = "0.52.6" 572 | source = "registry+https://github.com/rust-lang/crates.io-index" 573 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 574 | dependencies = [ 575 | "windows_aarch64_gnullvm", 576 | "windows_aarch64_msvc", 577 | "windows_i686_gnu", 578 | "windows_i686_gnullvm", 579 | "windows_i686_msvc", 580 | "windows_x86_64_gnu", 581 | "windows_x86_64_gnullvm", 582 | "windows_x86_64_msvc", 583 | ] 584 | 585 | [[package]] 586 | name = "windows_aarch64_gnullvm" 587 | version = "0.52.6" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 590 | 591 | [[package]] 592 | name = "windows_aarch64_msvc" 593 | version = "0.52.6" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 596 | 597 | [[package]] 598 | name = "windows_i686_gnu" 599 | version = "0.52.6" 600 | source = "registry+https://github.com/rust-lang/crates.io-index" 601 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 602 | 603 | [[package]] 604 | name = "windows_i686_gnullvm" 605 | version = "0.52.6" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 608 | 609 | [[package]] 610 | name = "windows_i686_msvc" 611 | version = "0.52.6" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 614 | 615 | [[package]] 616 | name = "windows_x86_64_gnu" 617 | version = "0.52.6" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 620 | 621 | [[package]] 622 | name = "windows_x86_64_gnullvm" 623 | version = "0.52.6" 624 | source = "registry+https://github.com/rust-lang/crates.io-index" 625 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 626 | 627 | [[package]] 628 | name = "windows_x86_64_msvc" 629 | version = "0.52.6" 630 | source = "registry+https://github.com/rust-lang/crates.io-index" 631 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 632 | -------------------------------------------------------------------------------- /rust_async_std/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust_async_std" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | async-std = { version = "1.13.0", features = ["attributes"] } 8 | -------------------------------------------------------------------------------- /rust_async_std/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use async_std::task; 3 | use std::time::Duration; 4 | 5 | #[async_std::main] 6 | async fn main() { 7 | let num_tasks = env::args().skip(1).next().unwrap().parse().unwrap(); 8 | 9 | let mut tasks = Vec::with_capacity(num_tasks); 10 | for _ in 0..num_tasks { 11 | tasks.push(task::spawn(task::sleep(Duration::from_secs(10)))); 12 | } 13 | 14 | for task in tasks { 15 | task.await; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /rust_futures/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.24.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler2" 16 | version = "2.0.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" 19 | 20 | [[package]] 21 | name = "autocfg" 22 | version = "1.4.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 25 | 26 | [[package]] 27 | name = "backtrace" 28 | version = "0.3.74" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" 31 | dependencies = [ 32 | "addr2line", 33 | "cfg-if", 34 | "libc", 35 | "miniz_oxide", 36 | "object", 37 | "rustc-demangle", 38 | "windows-targets", 39 | ] 40 | 41 | [[package]] 42 | name = "bitflags" 43 | version = "2.6.0" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 46 | 47 | [[package]] 48 | name = "bytes" 49 | version = "1.9.0" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" 52 | 53 | [[package]] 54 | name = "cfg-if" 55 | version = "1.0.0" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 58 | 59 | [[package]] 60 | name = "futures" 61 | version = "0.3.31" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" 64 | dependencies = [ 65 | "futures-channel", 66 | "futures-core", 67 | "futures-executor", 68 | "futures-io", 69 | "futures-sink", 70 | "futures-task", 71 | "futures-util", 72 | ] 73 | 74 | [[package]] 75 | name = "futures-channel" 76 | version = "0.3.31" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" 79 | dependencies = [ 80 | "futures-core", 81 | "futures-sink", 82 | ] 83 | 84 | [[package]] 85 | name = "futures-core" 86 | version = "0.3.31" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" 89 | 90 | [[package]] 91 | name = "futures-executor" 92 | version = "0.3.31" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" 95 | dependencies = [ 96 | "futures-core", 97 | "futures-task", 98 | "futures-util", 99 | ] 100 | 101 | [[package]] 102 | name = "futures-io" 103 | version = "0.3.31" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" 106 | 107 | [[package]] 108 | name = "futures-macro" 109 | version = "0.3.31" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" 112 | dependencies = [ 113 | "proc-macro2", 114 | "quote", 115 | "syn", 116 | ] 117 | 118 | [[package]] 119 | name = "futures-sink" 120 | version = "0.3.31" 121 | source = "registry+https://github.com/rust-lang/crates.io-index" 122 | checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" 123 | 124 | [[package]] 125 | name = "futures-task" 126 | version = "0.3.31" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" 129 | 130 | [[package]] 131 | name = "futures-util" 132 | version = "0.3.31" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" 135 | dependencies = [ 136 | "futures-channel", 137 | "futures-core", 138 | "futures-io", 139 | "futures-macro", 140 | "futures-sink", 141 | "futures-task", 142 | "memchr", 143 | "pin-project-lite", 144 | "pin-utils", 145 | "slab", 146 | ] 147 | 148 | [[package]] 149 | name = "gimli" 150 | version = "0.31.1" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" 153 | 154 | [[package]] 155 | name = "libc" 156 | version = "0.2.166" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" 159 | 160 | [[package]] 161 | name = "lock_api" 162 | version = "0.4.12" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" 165 | dependencies = [ 166 | "autocfg", 167 | "scopeguard", 168 | ] 169 | 170 | [[package]] 171 | name = "memchr" 172 | version = "2.7.4" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 175 | 176 | [[package]] 177 | name = "miniz_oxide" 178 | version = "0.8.0" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" 181 | dependencies = [ 182 | "adler2", 183 | ] 184 | 185 | [[package]] 186 | name = "mio" 187 | version = "1.0.3" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" 190 | dependencies = [ 191 | "libc", 192 | "wasi", 193 | "windows-sys", 194 | ] 195 | 196 | [[package]] 197 | name = "object" 198 | version = "0.36.5" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" 201 | dependencies = [ 202 | "memchr", 203 | ] 204 | 205 | [[package]] 206 | name = "parking_lot" 207 | version = "0.12.3" 208 | source = "registry+https://github.com/rust-lang/crates.io-index" 209 | checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" 210 | dependencies = [ 211 | "lock_api", 212 | "parking_lot_core", 213 | ] 214 | 215 | [[package]] 216 | name = "parking_lot_core" 217 | version = "0.9.10" 218 | source = "registry+https://github.com/rust-lang/crates.io-index" 219 | checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" 220 | dependencies = [ 221 | "cfg-if", 222 | "libc", 223 | "redox_syscall", 224 | "smallvec", 225 | "windows-targets", 226 | ] 227 | 228 | [[package]] 229 | name = "pin-project-lite" 230 | version = "0.2.15" 231 | source = "registry+https://github.com/rust-lang/crates.io-index" 232 | checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" 233 | 234 | [[package]] 235 | name = "pin-utils" 236 | version = "0.1.0" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 239 | 240 | [[package]] 241 | name = "proc-macro2" 242 | version = "1.0.92" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" 245 | dependencies = [ 246 | "unicode-ident", 247 | ] 248 | 249 | [[package]] 250 | name = "quote" 251 | version = "1.0.37" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" 254 | dependencies = [ 255 | "proc-macro2", 256 | ] 257 | 258 | [[package]] 259 | name = "redox_syscall" 260 | version = "0.5.7" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" 263 | dependencies = [ 264 | "bitflags", 265 | ] 266 | 267 | [[package]] 268 | name = "rust_futures" 269 | version = "0.1.0" 270 | dependencies = [ 271 | "futures", 272 | "tokio", 273 | ] 274 | 275 | [[package]] 276 | name = "rustc-demangle" 277 | version = "0.1.24" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" 280 | 281 | [[package]] 282 | name = "scopeguard" 283 | version = "1.2.0" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 286 | 287 | [[package]] 288 | name = "signal-hook-registry" 289 | version = "1.4.2" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" 292 | dependencies = [ 293 | "libc", 294 | ] 295 | 296 | [[package]] 297 | name = "slab" 298 | version = "0.4.9" 299 | source = "registry+https://github.com/rust-lang/crates.io-index" 300 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 301 | dependencies = [ 302 | "autocfg", 303 | ] 304 | 305 | [[package]] 306 | name = "smallvec" 307 | version = "1.13.2" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 310 | 311 | [[package]] 312 | name = "socket2" 313 | version = "0.5.8" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" 316 | dependencies = [ 317 | "libc", 318 | "windows-sys", 319 | ] 320 | 321 | [[package]] 322 | name = "syn" 323 | version = "2.0.89" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" 326 | dependencies = [ 327 | "proc-macro2", 328 | "quote", 329 | "unicode-ident", 330 | ] 331 | 332 | [[package]] 333 | name = "tokio" 334 | version = "1.41.1" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" 337 | dependencies = [ 338 | "backtrace", 339 | "bytes", 340 | "libc", 341 | "mio", 342 | "parking_lot", 343 | "pin-project-lite", 344 | "signal-hook-registry", 345 | "socket2", 346 | "tokio-macros", 347 | "windows-sys", 348 | ] 349 | 350 | [[package]] 351 | name = "tokio-macros" 352 | version = "2.4.0" 353 | source = "registry+https://github.com/rust-lang/crates.io-index" 354 | checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" 355 | dependencies = [ 356 | "proc-macro2", 357 | "quote", 358 | "syn", 359 | ] 360 | 361 | [[package]] 362 | name = "unicode-ident" 363 | version = "1.0.14" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" 366 | 367 | [[package]] 368 | name = "wasi" 369 | version = "0.11.0+wasi-snapshot-preview1" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 372 | 373 | [[package]] 374 | name = "windows-sys" 375 | version = "0.52.0" 376 | source = "registry+https://github.com/rust-lang/crates.io-index" 377 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 378 | dependencies = [ 379 | "windows-targets", 380 | ] 381 | 382 | [[package]] 383 | name = "windows-targets" 384 | version = "0.52.6" 385 | source = "registry+https://github.com/rust-lang/crates.io-index" 386 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 387 | dependencies = [ 388 | "windows_aarch64_gnullvm", 389 | "windows_aarch64_msvc", 390 | "windows_i686_gnu", 391 | "windows_i686_gnullvm", 392 | "windows_i686_msvc", 393 | "windows_x86_64_gnu", 394 | "windows_x86_64_gnullvm", 395 | "windows_x86_64_msvc", 396 | ] 397 | 398 | [[package]] 399 | name = "windows_aarch64_gnullvm" 400 | version = "0.52.6" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 403 | 404 | [[package]] 405 | name = "windows_aarch64_msvc" 406 | version = "0.52.6" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 409 | 410 | [[package]] 411 | name = "windows_i686_gnu" 412 | version = "0.52.6" 413 | source = "registry+https://github.com/rust-lang/crates.io-index" 414 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 415 | 416 | [[package]] 417 | name = "windows_i686_gnullvm" 418 | version = "0.52.6" 419 | source = "registry+https://github.com/rust-lang/crates.io-index" 420 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 421 | 422 | [[package]] 423 | name = "windows_i686_msvc" 424 | version = "0.52.6" 425 | source = "registry+https://github.com/rust-lang/crates.io-index" 426 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 427 | 428 | [[package]] 429 | name = "windows_x86_64_gnu" 430 | version = "0.52.6" 431 | source = "registry+https://github.com/rust-lang/crates.io-index" 432 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 433 | 434 | [[package]] 435 | name = "windows_x86_64_gnullvm" 436 | version = "0.52.6" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 439 | 440 | [[package]] 441 | name = "windows_x86_64_msvc" 442 | version = "0.52.6" 443 | source = "registry+https://github.com/rust-lang/crates.io-index" 444 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 445 | -------------------------------------------------------------------------------- /rust_futures/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust_futures" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | futures = "0.3.31" 8 | tokio = { version = "1.41.1", features = ["full"] } 9 | -------------------------------------------------------------------------------- /rust_futures/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::time::Duration; 3 | 4 | #[tokio::main] 5 | async fn main() { 6 | let num_tasks = env::args().skip(1).next().unwrap().parse().unwrap(); 7 | 8 | futures::future::join_all((0..num_tasks).map(|_| tokio::time::sleep(Duration::from_secs(10)))) 9 | .await; 10 | } 11 | -------------------------------------------------------------------------------- /rust_tokio/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.24.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler2" 16 | version = "2.0.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" 19 | 20 | [[package]] 21 | name = "autocfg" 22 | version = "1.4.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 25 | 26 | [[package]] 27 | name = "backtrace" 28 | version = "0.3.74" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" 31 | dependencies = [ 32 | "addr2line", 33 | "cfg-if", 34 | "libc", 35 | "miniz_oxide", 36 | "object", 37 | "rustc-demangle", 38 | "windows-targets", 39 | ] 40 | 41 | [[package]] 42 | name = "bitflags" 43 | version = "2.6.0" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 46 | 47 | [[package]] 48 | name = "bytes" 49 | version = "1.9.0" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" 52 | 53 | [[package]] 54 | name = "cfg-if" 55 | version = "1.0.0" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 58 | 59 | [[package]] 60 | name = "gimli" 61 | version = "0.31.1" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" 64 | 65 | [[package]] 66 | name = "libc" 67 | version = "0.2.166" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" 70 | 71 | [[package]] 72 | name = "lock_api" 73 | version = "0.4.12" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" 76 | dependencies = [ 77 | "autocfg", 78 | "scopeguard", 79 | ] 80 | 81 | [[package]] 82 | name = "memchr" 83 | version = "2.7.4" 84 | source = "registry+https://github.com/rust-lang/crates.io-index" 85 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 86 | 87 | [[package]] 88 | name = "miniz_oxide" 89 | version = "0.8.0" 90 | source = "registry+https://github.com/rust-lang/crates.io-index" 91 | checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" 92 | dependencies = [ 93 | "adler2", 94 | ] 95 | 96 | [[package]] 97 | name = "mio" 98 | version = "1.0.3" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" 101 | dependencies = [ 102 | "libc", 103 | "wasi", 104 | "windows-sys", 105 | ] 106 | 107 | [[package]] 108 | name = "object" 109 | version = "0.36.5" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" 112 | dependencies = [ 113 | "memchr", 114 | ] 115 | 116 | [[package]] 117 | name = "parking_lot" 118 | version = "0.12.3" 119 | source = "registry+https://github.com/rust-lang/crates.io-index" 120 | checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" 121 | dependencies = [ 122 | "lock_api", 123 | "parking_lot_core", 124 | ] 125 | 126 | [[package]] 127 | name = "parking_lot_core" 128 | version = "0.9.10" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" 131 | dependencies = [ 132 | "cfg-if", 133 | "libc", 134 | "redox_syscall", 135 | "smallvec", 136 | "windows-targets", 137 | ] 138 | 139 | [[package]] 140 | name = "pin-project-lite" 141 | version = "0.2.15" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" 144 | 145 | [[package]] 146 | name = "proc-macro2" 147 | version = "1.0.92" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" 150 | dependencies = [ 151 | "unicode-ident", 152 | ] 153 | 154 | [[package]] 155 | name = "quote" 156 | version = "1.0.37" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" 159 | dependencies = [ 160 | "proc-macro2", 161 | ] 162 | 163 | [[package]] 164 | name = "redox_syscall" 165 | version = "0.5.7" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" 168 | dependencies = [ 169 | "bitflags", 170 | ] 171 | 172 | [[package]] 173 | name = "rust_tokio" 174 | version = "0.1.0" 175 | dependencies = [ 176 | "tokio", 177 | ] 178 | 179 | [[package]] 180 | name = "rustc-demangle" 181 | version = "0.1.24" 182 | source = "registry+https://github.com/rust-lang/crates.io-index" 183 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" 184 | 185 | [[package]] 186 | name = "scopeguard" 187 | version = "1.2.0" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 190 | 191 | [[package]] 192 | name = "signal-hook-registry" 193 | version = "1.4.2" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" 196 | dependencies = [ 197 | "libc", 198 | ] 199 | 200 | [[package]] 201 | name = "smallvec" 202 | version = "1.13.2" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 205 | 206 | [[package]] 207 | name = "socket2" 208 | version = "0.5.8" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" 211 | dependencies = [ 212 | "libc", 213 | "windows-sys", 214 | ] 215 | 216 | [[package]] 217 | name = "syn" 218 | version = "2.0.89" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" 221 | dependencies = [ 222 | "proc-macro2", 223 | "quote", 224 | "unicode-ident", 225 | ] 226 | 227 | [[package]] 228 | name = "tokio" 229 | version = "1.41.1" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" 232 | dependencies = [ 233 | "backtrace", 234 | "bytes", 235 | "libc", 236 | "mio", 237 | "parking_lot", 238 | "pin-project-lite", 239 | "signal-hook-registry", 240 | "socket2", 241 | "tokio-macros", 242 | "windows-sys", 243 | ] 244 | 245 | [[package]] 246 | name = "tokio-macros" 247 | version = "2.4.0" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" 250 | dependencies = [ 251 | "proc-macro2", 252 | "quote", 253 | "syn", 254 | ] 255 | 256 | [[package]] 257 | name = "unicode-ident" 258 | version = "1.0.14" 259 | source = "registry+https://github.com/rust-lang/crates.io-index" 260 | checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" 261 | 262 | [[package]] 263 | name = "wasi" 264 | version = "0.11.0+wasi-snapshot-preview1" 265 | source = "registry+https://github.com/rust-lang/crates.io-index" 266 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 267 | 268 | [[package]] 269 | name = "windows-sys" 270 | version = "0.52.0" 271 | source = "registry+https://github.com/rust-lang/crates.io-index" 272 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 273 | dependencies = [ 274 | "windows-targets", 275 | ] 276 | 277 | [[package]] 278 | name = "windows-targets" 279 | version = "0.52.6" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 282 | dependencies = [ 283 | "windows_aarch64_gnullvm", 284 | "windows_aarch64_msvc", 285 | "windows_i686_gnu", 286 | "windows_i686_gnullvm", 287 | "windows_i686_msvc", 288 | "windows_x86_64_gnu", 289 | "windows_x86_64_gnullvm", 290 | "windows_x86_64_msvc", 291 | ] 292 | 293 | [[package]] 294 | name = "windows_aarch64_gnullvm" 295 | version = "0.52.6" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 298 | 299 | [[package]] 300 | name = "windows_aarch64_msvc" 301 | version = "0.52.6" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 304 | 305 | [[package]] 306 | name = "windows_i686_gnu" 307 | version = "0.52.6" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 310 | 311 | [[package]] 312 | name = "windows_i686_gnullvm" 313 | version = "0.52.6" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 316 | 317 | [[package]] 318 | name = "windows_i686_msvc" 319 | version = "0.52.6" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 322 | 323 | [[package]] 324 | name = "windows_x86_64_gnu" 325 | version = "0.52.6" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 328 | 329 | [[package]] 330 | name = "windows_x86_64_gnullvm" 331 | version = "0.52.6" 332 | source = "registry+https://github.com/rust-lang/crates.io-index" 333 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 334 | 335 | [[package]] 336 | name = "windows_x86_64_msvc" 337 | version = "0.52.6" 338 | source = "registry+https://github.com/rust-lang/crates.io-index" 339 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 340 | -------------------------------------------------------------------------------- /rust_tokio/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust_tokio" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | tokio = { version = "1.41.1", features = ["full"] } 8 | -------------------------------------------------------------------------------- /rust_tokio/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use tokio::{spawn, time::{sleep, Duration}}; 3 | 4 | #[tokio::main] 5 | async fn main() { 6 | let num_tasks = env::args().skip(1).next().unwrap().parse().unwrap(); 7 | 8 | let mut tasks = Vec::with_capacity(num_tasks); 9 | for _ in 0..num_tasks { 10 | tasks.push(spawn(sleep(Duration::from_secs(10)))); 11 | } 12 | for task in tasks { 13 | task.await.unwrap(); 14 | } 15 | } 16 | --------------------------------------------------------------------------------