Hevake Lee

Results 4 comments of Hevake Lee

你好,我的项目中的http是支持管线化的。 同时还支持异步响应、类似Node.js的Router。代码如下: https://github.com/hevake/cpp-tbox/blob/master/modules/http/server/server_imp.cpp 欢迎使用 cpp-tbox。

针对这个问题,我在 cpp-tbox 中使用了比较另类的方法。 如果在一个对象的回调中要释放自己。它不能直接 delete,而是委托给 loop 在下一个事件中去做。 ``` auto tobe_delete = object_ptr_; obejct_ptr_ = nullptr; loop->runInLoop([tobe_delete] {delete tobe_delete;}); ``` 如果是智能指针的话,就: ``` auto tobe_delete = std::move(object_ptr_); loop->runInLoop([tobe_delete] {}); ``` 在我的开源项目 cpp-tbox...

另外,我在大部分的事件对象中都有加 cb_level_,用于监控是否存在在自己的回调中析构自己的情况。 在回调的时候: ``` ++cb_level_; cb(); --cb_level_; ``` 在析构的时候,就检查cb_level_是否为0。如果为0,则表示发生了这情况。就报断言。 如:https://github.com/hevake/cpp-tbox/blob/master/modules/event/timer_event_impl.cpp

> fatal error: tbox/base/defines.h: No such file or directory 44 | #include | ^~~~~~~~~~~~~~~~~~~~~ compilation terminated. Did you discover this problem when building your own project, or did the problem...