Skip to content

Instantly share code, notes, and snippets.

View smallfish's full-sized avatar

smallfish smallfish

View GitHub Profile
@smallfish
smallfish / Cargo.toml
Last active October 19, 2021 13:07
axum route with default layer and tower::ServiceBuilder layer
[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"
@smallfish
smallfish / Cargo.toml
Last active December 10, 2020 01:35
tokio-0.2-0.3 thread panicked at 'there is no reactor running, must be called from the context of Tokio runtime'
[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"
#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);