1
This commit is contained in:
parent
99cae679b9
commit
edcd30b9e0
@ -18,6 +18,7 @@
|
||||
#include "app.h"
|
||||
#include "handlermgr.h"
|
||||
#include "httpproxy.h"
|
||||
#include "playermgr.h"
|
||||
|
||||
#include "ss_msgid.pb.h"
|
||||
#include "ss_proto.pb.h"
|
||||
@ -95,7 +96,7 @@ bool App::Init(int argc, char* argv[])
|
||||
#endif
|
||||
uuid.SetMachineId((node_id - 1) * MAX_NODE_ID + instance_id);
|
||||
HttpProxy::Instance()->Init();
|
||||
|
||||
PlayerMgr::Instance()->Init();
|
||||
{
|
||||
int perf_log_time = 1000 * 30;
|
||||
f8::Timer::Instance()->SetInterval
|
||||
@ -126,6 +127,7 @@ void App::UnInit()
|
||||
{
|
||||
//const char* s2 = GetEnumString<int>();
|
||||
//int i = static_cast<int>(Test_e::kFlyBuffId);
|
||||
PlayerMgr::Instance()->UnInit();
|
||||
HttpProxy::Instance()->UnInit();
|
||||
f8::BtMgr::Instance()->UnInit();
|
||||
f8::HttpClientPool::Instance()->UnInit();
|
||||
|
22
server/robotserver/comgr.cc
Normal file
22
server/robotserver/comgr.cc
Normal file
@ -0,0 +1,22 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "comgr.h"
|
||||
#include "coroutine.h"
|
||||
|
||||
void CoMgr::Init()
|
||||
{
|
||||
INIT_LIST_HEAD(&co_list_);
|
||||
}
|
||||
|
||||
void CoMgr::UnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CoMgr::Update()
|
||||
{
|
||||
Coroutine *co = nullptr, *tmp = nullptr;
|
||||
list_for_each_entry_safe(co, tmp, &co_list_, entry) {
|
||||
co->Exec();
|
||||
}
|
||||
}
|
22
server/robotserver/comgr.h
Normal file
22
server/robotserver/comgr.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <a8/singleton.h>
|
||||
|
||||
class CoMgr : public a8::Singleton<CoMgr>
|
||||
{
|
||||
|
||||
private:
|
||||
CoMgr() {};
|
||||
friend class a8::Singleton<CoMgr>;
|
||||
|
||||
public:
|
||||
|
||||
void Init();
|
||||
void UnInit();
|
||||
void Update();
|
||||
|
||||
private:
|
||||
|
||||
list_head co_list_;
|
||||
|
||||
};
|
@ -1,16 +1,30 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "coroutine.h"
|
||||
|
||||
Coroutine::Coroutine(std::function<void(Coroutine*)> cb)
|
||||
{
|
||||
INIT_LIST_HEAD(&entry);
|
||||
cb_ = cb;
|
||||
source_ = std::make_shared<boost::coroutines2::coroutine<void>::pull_type>
|
||||
(
|
||||
[this] (boost::coroutines2::coroutine<void>::push_type& sink)
|
||||
{
|
||||
CallEnter(sink);
|
||||
cb_(this);
|
||||
CallExit(sink);
|
||||
});
|
||||
while (*source_) {
|
||||
a8::XPrintf("xxxxx\n", {});
|
||||
(*source_)();
|
||||
}
|
||||
}
|
||||
|
||||
void Coroutine::Exec()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Coroutine::CoSuspend()
|
||||
@ -23,6 +37,11 @@ void Coroutine::CoResume()
|
||||
|
||||
}
|
||||
|
||||
void Coroutine::CoYield()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Coroutine::CoAwait(Awaiter& awaiter)
|
||||
{
|
||||
|
||||
@ -32,3 +51,13 @@ void Coroutine::CoAwait(Awaiter* awaiter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Coroutine::CallEnter(boost::coroutines2::coroutine<void>::push_type& sink)
|
||||
{
|
||||
sink_ = &sink;
|
||||
}
|
||||
|
||||
void Coroutine::CallExit(boost::coroutines2::coroutine<void>::push_type& sink)
|
||||
{
|
||||
sink_ = nullptr;
|
||||
}
|
||||
|
@ -15,15 +15,24 @@ class Promise : public Awaiter
|
||||
class Coroutine : public Awaiter
|
||||
{
|
||||
public:
|
||||
list_head entry;
|
||||
|
||||
Coroutine(std::function<void(Coroutine*)> cb);
|
||||
|
||||
void Exec();
|
||||
void CoSuspend();
|
||||
void CoResume();
|
||||
void CoYield();
|
||||
void CoAwait(Awaiter& awaiter);
|
||||
void CoAwait(Awaiter* awaiter);
|
||||
|
||||
private:
|
||||
|
||||
void CallEnter(boost::coroutines2::coroutine<void>::push_type& sink);
|
||||
void CallExit(boost::coroutines2::coroutine<void>::push_type& sink);
|
||||
|
||||
private:
|
||||
std::shared_ptr<boost::coroutines2::coroutine<void>::pull_type> source_;
|
||||
std::function<void(Coroutine* co)> cb_;
|
||||
boost::coroutines2::coroutine<void>::push_type* sink_ = nullptr;
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "playermgr.h"
|
||||
#include "player.h"
|
||||
#include "coroutine.h"
|
||||
|
||||
#include <f8/utils.h>
|
||||
#include <f8/msgqueue.h>
|
||||
@ -15,6 +16,12 @@ void PlayerMgr::Init()
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
}
|
||||
Coroutine co
|
||||
(
|
||||
[] (Coroutine* co)
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void PlayerMgr::UnInit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user