wd-event
介绍
rust版事件系统
软件架构
软件架构说明
安装教程
wd_event = "0.1.0"
使用说明
The event function is inspired by c#, and based on the event system, we can achieve program decoupling more easily. So rust has also implemented a similar, but richer, lightweight event development package. Project development address:
The event functions implemented with rust are as follows:
- event add and execute
- Context
- delay event,delay cycle event
- task pool
- object pool
extern wd-event crate
use ;
create a event manager
async
add a event
If a structure implements the Event trait,it can be registered.
- EType::Default: Execute the Event's handle method.
- EType::Mutable: Execute the Event's handle_mut method.
- EType::Async: Execute a async event.
sync
;
let event_one = Stringfrom;
es.add.unwrap;
async ** exec_sequence function execute async event is nonsegmented **
;
es.add_async.unwrap;
execute event , non-blocking
- exec_sequence: Execute in order, register first execute first.
- exec_pool: Execute events through the task pool.
- exec_immediately: Execute the event asynchronously immediately.
es.exec_sequence;
es.exec_pool;
es.exec_immediately.await;;
Context
Context is used to pass state and share messages in multiple callbacks to an event. Changing the status of Context will stop the subsequent function calls, only the exec_sequence method and cycle event. Refer to the API documentation for more methods.
//Create context and add a default message
let a:i32 = 1;
es.exec_sequence;
//Gets the default message for the context
//
delay event,delay cycle event
//delay event and cycle event. only the handle_mut method is called
//Once a second
es.delay_exec;
task pool
Task pool functionality, integrated into the event manager. Using the exec_pool function. Of course, the task pool function can also be used separately, as detailed in the API documentation.
object pool
Object pool, currently only a simple implementation. It is worth considering whether rust really needs object pools.
参与贡献
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request
特技
- 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
- Gitee 官方博客 blog.gitee.com
- 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
- GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
- Gitee 官方提供的使用手册 https://gitee.com/help
- Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/