forked from DragonOS-Community/DragonOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 增加tokio异步运行时支持 (DragonOS-Community#894)
* fix the EventFdFlags error * feat: support tokio (Single thread version) Fix deadlock issue on closing file. Add function for PipeInode and EventFdInode.
- Loading branch information
Showing
9 changed files
with
192 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/target | ||
Cargo.lock | ||
/install/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "test_tokio" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
tokio = { version = "1.25", features = [ | ||
"macros", | ||
"rt", | ||
"rt-multi-thread", | ||
"net", | ||
"signal", | ||
] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" | ||
RUSTFLAGS+="" | ||
|
||
ifdef DADK_CURRENT_BUILD_DIR | ||
# 如果是在dadk中编译,那么安装到dadk的安装目录中 | ||
INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR) | ||
else | ||
# 如果是在本地编译,那么安装到当前目录下的install目录中 | ||
INSTALL_DIR = ./install | ||
endif | ||
|
||
ifeq ($(ARCH), x86_64) | ||
export RUST_TARGET=x86_64-unknown-linux-musl | ||
else ifeq ($(ARCH), riscv64) | ||
export RUST_TARGET=riscv64gc-unknown-linux-gnu | ||
else | ||
# 默认为x86_86,用于本地编译 | ||
export RUST_TARGET=x86_64-unknown-linux-musl | ||
endif | ||
|
||
run: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) | ||
|
||
build: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) | ||
|
||
clean: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) | ||
|
||
test: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) | ||
|
||
doc: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET) | ||
|
||
fmt: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt | ||
|
||
fmt-check: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check | ||
|
||
run-release: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release | ||
|
||
build-release: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release | ||
|
||
clean-release: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release | ||
|
||
test-release: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release | ||
|
||
.PHONY: install | ||
install: | ||
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use tokio::signal; | ||
|
||
async fn say_world() { | ||
println!("world"); | ||
} | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() { | ||
// Calling `say_world()` does not execute the body of `say_world()`. | ||
let op = say_world(); | ||
|
||
// This println! comes first | ||
println!("hello"); | ||
|
||
// Calling `.await` on `op` starts executing `say_world`. | ||
op.await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "test_tokio", | ||
"version": "0.1.0", | ||
"description": "测试tokio", | ||
"task_type": { | ||
"BuildFromSource": { | ||
"Local": { | ||
"path": "apps/test_tokio" | ||
} | ||
} | ||
}, | ||
"depends": [], | ||
"build": { | ||
"build_command": "make install" | ||
}, | ||
"clean": { | ||
"clean_command": "make clean" | ||
}, | ||
"install": { | ||
"in_dragonos_path": "/" | ||
}, | ||
"target_arch": ["x86_64"] | ||
} |