f8/test/app.h
2019-02-11 11:55:53 +08:00

60 lines
1.1 KiB
C++

#pragma once
#include <a8/uuid.h>
struct IMMsgNode;
class App : public a8::Singleton<App>
{
private:
App() {};
friend class a8::Singleton<App>;
public:
void Init(int argc, char* argv[]);
void UnInit();
int Run();
void AddIMMsg(unsigned short imcmd, a8::XParams params);
void NotifyLoopCond();
a8::XParams* AddContext(long long context_id);
void DelContext(long long context_id);
a8::XParams* GetContext(long long context_id);
private:
void QuickExecute();
void SlowerExecute();
void Schedule();
bool HasTask();
void ProcessIMMsg();
void InitLog();
void UnInitLog();
bool ParseOpt();
public:
int argc = 0;
char** argv = nullptr;
volatile bool terminated = false;
public:
int instance_id = 0;
private:
std::mutex *loop_mutex_ = nullptr;
std::condition_variable *loop_cond_ = nullptr;
std::mutex* im_msg_mutex_ = nullptr;
IMMsgNode* im_top_node_ = nullptr;
IMMsgNode* im_bot_node_ = nullptr;
IMMsgNode* im_work_node_ = nullptr;
std::map<long long, a8::XParams> context_hash_;
};