diff --git a/f8/app.cc b/f8/app.cc new file mode 100644 index 0000000..411cbc3 --- /dev/null +++ b/f8/app.cc @@ -0,0 +1,6 @@ +#include +#include + +#include + +#include diff --git a/f8/app.h b/f8/app.h new file mode 100644 index 0000000..526abd6 --- /dev/null +++ b/f8/app.h @@ -0,0 +1,58 @@ +#pragma once + +#include + +namespace a8 +{ + namespace uuid + { + class SnowFlake; + } +} + +namespace f8 +{ + + class UserApp + { + public: + virtual const std::string GetPkgName() = 0; + virtual void Init() = 0; + virtual void UnInit() = 0; + virtual void Update() = 0; + }; + + class App : public a8::Singleton + { + private: + App() {}; + friend class a8::Singleton; + + void Run(UserApp* user_app); + + const std::string GetPkgName(); + void NotifyLoopCond(); + bool HasFlag(int flag); + long long NewUuid(); + int GetZoneId() { return zone_id_; } + int GetNodeId() { return node_id_; } + int GetInstanceId() { return instance_id_; } + + private: + UserApp* user_app_ = nullptr; + int argc_ = 0; + char** argv_ = nullptr; + volatile bool terminated_ = false; + volatile bool shutdowned_ = false; + + int zone_id_ = 0; + int node_id_ = 0; + int instance_id_ = 0; + std::set flags_; + + std::shared_ptr uuid_; + std::mutex *loop_mutex_ = nullptr; + std::condition_variable *loop_cond_ = nullptr; + }; + +}