适用于 macOS 系统,依赖:
- openresty https://openresty.org/cn/installation.html
- redis
$ brew install openresty/brew/openresty
..| [dependencies] | |
| tokio = { version = "1.0", features = ["full"] } | |
| futures = "0.3.1" | |
| axum = { version = "0.2", features = ["headers"] } | |
| tower = { version = "0.4", features = ["full"] } | |
| log = "0.4.0" | |
| env_logger = "0.8.4" | |
| async-trait = "0.1.51" |
| [package] | |
| name = "hello-tokio" | |
| version = "0.1.0" | |
| authors = ["smallfish"] | |
| edition = "2018" | |
| [dependencies] | |
| tokio = { version = "0.2", features = ["full"] } | |
| #tokio = { version = "0.3", features = ["full"] } | |
| actix-web = "3.0.2" |
适用于 macOS 系统,依赖:
$ brew install openresty/brew/openresty
..| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #include <pthread.h> | |
| #include <time.h> | |
| void *test(int id) { | |
| int r = 10 + rand() % 5; | |
| printf("[%d] id: %d sleep(%d) start\n", getpid(), id, r); | |
| sleep(r); |