Skip to content

Commit

Permalink
fix compile error2
Browse files Browse the repository at this point in the history
  • Loading branch information
lkpworkspace committed Jun 20, 2024
1 parent 1f8e35b commit 7fd0339
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/example_worker_interactive_with_3rd_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class ExampleWorkerInteractiveWith3rdFrame : public myframe::Worker {
recv_run_flag_ = true;
} else if (cmd == myframe::CmdChannel::Cmd::kRunWithMsg) {
auto mailbox = GetMailbox();
while (!mailbox->RecvEmpty()) {
const auto msg = mailbox->PopRecv();
while (!mailbox->RunEmpty()) {
const auto msg = mailbox->PopRun();
// 接收到其它组件消息
LOG(INFO) << "get main " << msg->GetData();
}
Expand Down
6 changes: 5 additions & 1 deletion myframe/mailbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ bool Mailbox::RunEmpty() const {
return run_.empty();
}

int Mailbox::RunSize() const {
return run_.size();
}

const std::shared_ptr<const Msg> Mailbox::PopRun() {
if (run_.empty()) {
return nullptr;
Expand All @@ -112,7 +116,7 @@ std::list<std::shared_ptr<Msg>>* Mailbox::GetRecvList() {
std::ostream& operator<<(std::ostream& out, const Mailbox& mailbox) {
out << mailbox.Addr() << " recv " << mailbox.RecvSize()
<< ", send " << mailbox.SendSize()
<< ", run " << mailbox.run_.size();
<< ", run " << mailbox.RunSize();
return out;
}

Expand Down
6 changes: 4 additions & 2 deletions myframe/mailbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace myframe {

class Msg;
class MYFRAME_EXPORT Mailbox final {
friend std::ostream& operator<<(std::ostream&, const Mailbox&);
friend class ActorContext;
friend class ActorContextManager;
friend class WorkerContext;
Expand Down Expand Up @@ -45,12 +44,15 @@ class MYFRAME_EXPORT Mailbox final {
/// 信件处理
void MoveToRun();
bool RunEmpty() const;
int RunSize() const;
const std::shared_ptr<const Msg> PopRun();

private:
/// 收件箱
int RecvSize() const;
bool RecvEmpty() const;

private:
/// 收件箱
void RecvClear();
void Recv(std::shared_ptr<Msg> msg);
void Recv(std::list<std::shared_ptr<Msg>>* msg_list);
Expand Down

0 comments on commit 7fd0339

Please sign in to comment.