This commit is contained in:
aozhiwei 2022-12-12 17:24:42 +08:00
parent fdce7c9025
commit 358c62df57
3 changed files with 32 additions and 0 deletions

10
a8/a8.h
View File

@ -3,6 +3,7 @@
#include <assert.h>
#include <any>
#include <string>
#include <vector>
#include <map>
@ -13,6 +14,7 @@
#include <functional>
#include <initializer_list>
#include <a8/args.h>
#include <a8/types.h>
#include <a8/list.h>
#include <a8/xvalue.h>
@ -31,6 +33,14 @@ namespace std
class condition_variable;
};
namespace google
{
namespace protobuf
{
class Message;
}
}
#define NEW_NET
#define A8_SAFE_DELETE(p) { if(p){delete(p); (p)=nullptr;} }
#define A8_DEFINE_RANGE_BIT(type, begin, end) ((((type)1) << (end + 1)) - 1) & (~((((type)1) << (begin + 0)) - 1))

20
a8/args.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef A8_ARGS_H
#define A8_ARGS_H
namespace a8
{
class Args
{
public:
Args(std::vector<std::any> args):args_(std::move(args)) {};
template <typename T>
T Get(size_t index) const { return std::any_cast<T>(args_.at(index));};
private:
std::vector<std::any> args_;
};
}
#endif

View File

@ -14,6 +14,8 @@ namespace a8
SendQueueNode* next = nullptr;
};
typedef std::function<void(const a8::Args&)> CommonCbProc;
const int INVALID_FD = -1;
const int INVALID_SOCKET = -1;
const int INVALID_SOCKET_HANDLE = 0;