#pragma once #include struct IMMsgNode; class App : public a8::Singleton { private: App() {}; friend class a8::Singleton; 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 context_hash_; };