1
This commit is contained in:
parent
6c39a6480d
commit
e1ab21d022
@ -36,3 +36,8 @@ void App::DispatchSocketMsg(f8::MsgHdr* hdr)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool App::PreprocessSocketMsg(f8::MsgHdr* hdr)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -13,5 +13,6 @@ public:
|
|||||||
virtual void Update(int delta_time) override;
|
virtual void Update(int delta_time) override;
|
||||||
virtual bool HasTask() override;
|
virtual bool HasTask() override;
|
||||||
virtual void DispatchSocketMsg(f8::MsgHdr* hdr) override;
|
virtual void DispatchSocketMsg(f8::MsgHdr* hdr) override;
|
||||||
|
virtual bool PreprocessSocketMsg(f8::MsgHdr* hdr) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
13
third_party/f8/f8/app.cc
vendored
13
third_party/f8/f8/app.cc
vendored
@ -51,7 +51,8 @@ namespace f8
|
|||||||
int instance_id_ = 0;
|
int instance_id_ = 0;
|
||||||
std::set<int> flags_;
|
std::set<int> flags_;
|
||||||
|
|
||||||
a8::Queue queue_;
|
a8::Queue net_data_queue_;
|
||||||
|
a8::Queue net_msg_queue_;
|
||||||
std::atomic<long long> msgnode_size_ = {0};
|
std::atomic<long long> msgnode_size_ = {0};
|
||||||
std::atomic<long long> working_msgnode_size_ = {0};
|
std::atomic<long long> working_msgnode_size_ = {0};
|
||||||
|
|
||||||
@ -169,8 +170,8 @@ namespace f8
|
|||||||
std::unique_lock<std::mutex> lk(*loop_mutex_);
|
std::unique_lock<std::mutex> lk(*loop_mutex_);
|
||||||
bool has_task = false;
|
bool has_task = false;
|
||||||
{
|
{
|
||||||
queue_.Fetch();
|
net_msg_queue_.Fetch();
|
||||||
if (!list_empty(queue_.GetWorkList())) {
|
if (!list_empty(net_msg_queue_.GetWorkList())) {
|
||||||
has_task = true;
|
has_task = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,8 +189,8 @@ namespace f8
|
|||||||
|
|
||||||
void DispatchNetMsg()
|
void DispatchNetMsg()
|
||||||
{
|
{
|
||||||
queue_.Fetch();
|
net_msg_queue_.Fetch();
|
||||||
list_head* work_list = queue_.GetWorkList();
|
list_head* work_list = net_msg_queue_.GetWorkList();
|
||||||
while (!list_empty(work_list)){
|
while (!list_empty(work_list)){
|
||||||
MsgHdr* hdr = list_first_entry(work_list, MsgHdr, entry);
|
MsgHdr* hdr = list_first_entry(work_list, MsgHdr, entry);
|
||||||
list_del_init(&hdr->entry);
|
list_del_init(&hdr->entry);
|
||||||
@ -223,7 +224,7 @@ namespace f8
|
|||||||
memmove((void*)hdr->buf, msgbody, bodylen);
|
memmove((void*)hdr->buf, msgbody, bodylen);
|
||||||
}
|
}
|
||||||
++msgnode_size_;
|
++msgnode_size_;
|
||||||
queue_.Push(&hdr->entry);
|
net_data_queue_.Push(&hdr->entry);
|
||||||
NotifyLoopCond();
|
NotifyLoopCond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
third_party/f8/f8/userapp.h
vendored
1
third_party/f8/f8/userapp.h
vendored
@ -13,6 +13,7 @@ namespace f8
|
|||||||
virtual void Update(int delta_time) = 0;
|
virtual void Update(int delta_time) = 0;
|
||||||
virtual bool HasTask() = 0;
|
virtual bool HasTask() = 0;
|
||||||
virtual void DispatchSocketMsg(f8::MsgHdr* hdr) = 0;
|
virtual void DispatchSocketMsg(f8::MsgHdr* hdr) = 0;
|
||||||
|
virtual bool PreprocessSocketMsg(f8::MsgHdr* hdr) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user