1
This commit is contained in:
parent
0b0158805f
commit
7843e73481
6
f8/app.cc
Normal file
6
f8/app.cc
Normal file
@ -0,0 +1,6 @@
|
||||
#include <a8/a8.h>
|
||||
#include <a8/uuid.h>
|
||||
|
||||
#include <f8/f8.h>
|
||||
|
||||
#include <f8/app.h>
|
58
f8/app.h
Normal file
58
f8/app.h
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <a8/singleton.h>
|
||||
|
||||
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<App>
|
||||
{
|
||||
private:
|
||||
App() {};
|
||||
friend class a8::Singleton<App>;
|
||||
|
||||
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<int> flags_;
|
||||
|
||||
std::shared_ptr<a8::uuid::SnowFlake> uuid_;
|
||||
std::mutex *loop_mutex_ = nullptr;
|
||||
std::condition_variable *loop_cond_ = nullptr;
|
||||
};
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user