From e1ab21d022b9458fad7d702a5fc694c486f15750 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 22 Dec 2024 21:32:01 +0800 Subject: [PATCH] 1 --- server/mymangosd/app.cc | 5 +++++ server/mymangosd/app.h | 1 + third_party/f8/f8/app.cc | 13 +++++++------ third_party/f8/f8/userapp.h | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/server/mymangosd/app.cc b/server/mymangosd/app.cc index c9e1dbb..b4c9592 100644 --- a/server/mymangosd/app.cc +++ b/server/mymangosd/app.cc @@ -36,3 +36,8 @@ void App::DispatchSocketMsg(f8::MsgHdr* hdr) { } + +bool App::PreprocessSocketMsg(f8::MsgHdr* hdr) +{ + return false; +} diff --git a/server/mymangosd/app.h b/server/mymangosd/app.h index 9333bd1..16fadd4 100644 --- a/server/mymangosd/app.h +++ b/server/mymangosd/app.h @@ -13,5 +13,6 @@ public: virtual void Update(int delta_time) override; virtual bool HasTask() override; virtual void DispatchSocketMsg(f8::MsgHdr* hdr) override; + virtual bool PreprocessSocketMsg(f8::MsgHdr* hdr) override; }; diff --git a/third_party/f8/f8/app.cc b/third_party/f8/f8/app.cc index c3c3054..af48ce0 100644 --- a/third_party/f8/f8/app.cc +++ b/third_party/f8/f8/app.cc @@ -51,7 +51,8 @@ namespace f8 int instance_id_ = 0; std::set flags_; - a8::Queue queue_; + a8::Queue net_data_queue_; + a8::Queue net_msg_queue_; std::atomic msgnode_size_ = {0}; std::atomic working_msgnode_size_ = {0}; @@ -169,8 +170,8 @@ namespace f8 std::unique_lock lk(*loop_mutex_); bool has_task = false; { - queue_.Fetch(); - if (!list_empty(queue_.GetWorkList())) { + net_msg_queue_.Fetch(); + if (!list_empty(net_msg_queue_.GetWorkList())) { has_task = true; } } @@ -188,8 +189,8 @@ namespace f8 void DispatchNetMsg() { - queue_.Fetch(); - list_head* work_list = queue_.GetWorkList(); + net_msg_queue_.Fetch(); + list_head* work_list = net_msg_queue_.GetWorkList(); while (!list_empty(work_list)){ MsgHdr* hdr = list_first_entry(work_list, MsgHdr, entry); list_del_init(&hdr->entry); @@ -223,7 +224,7 @@ namespace f8 memmove((void*)hdr->buf, msgbody, bodylen); } ++msgnode_size_; - queue_.Push(&hdr->entry); + net_data_queue_.Push(&hdr->entry); NotifyLoopCond(); } diff --git a/third_party/f8/f8/userapp.h b/third_party/f8/f8/userapp.h index 25ec329..2610461 100644 --- a/third_party/f8/f8/userapp.h +++ b/third_party/f8/f8/userapp.h @@ -13,6 +13,7 @@ namespace f8 virtual void Update(int delta_time) = 0; virtual bool HasTask() = 0; virtual void DispatchSocketMsg(f8::MsgHdr* hdr) = 0; + virtual bool PreprocessSocketMsg(f8::MsgHdr* hdr) = 0; }; }