36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
#pragma once
|
|
|
|
namespace f8
|
|
{
|
|
typedef std::function<void (const a8::XParams& param)> MsgHandleFunc;
|
|
typedef void CustomIMMsgFreeFunc(const a8::XParams& param);
|
|
typedef list_head* CallBackHandle;
|
|
|
|
class MsgQueueImp;
|
|
class MsgQueue : public a8::Singleton<MsgQueue>
|
|
{
|
|
private:
|
|
MsgQueue() {};
|
|
friend class a8::Singleton<MsgQueue>;
|
|
|
|
public:
|
|
void Init();
|
|
void UnInit();
|
|
|
|
void SendMsg(int msgid, a8::XParams param);
|
|
void PostMsg(int msgid, a8::XParams param);
|
|
void AddDelayMsg(int msgid, a8::XParams param, int milli_seconds);
|
|
void RemoveCallBack(CallBackHandle handle);
|
|
CallBackHandle RegisterCallBack(int msgid, MsgHandleFunc handle_func);
|
|
int AllocIMMsgId(CustomIMMsgFreeFunc free_func);
|
|
void FreeCustomIMMsg(a8::XParams& param);
|
|
void ProcessMsg(int msgid, const a8::XParams& param);
|
|
|
|
//线程安全版本
|
|
void PostMsg_r(int msgid, a8::XParams param);
|
|
|
|
private:
|
|
MsgQueueImp* imp_ = nullptr;
|
|
};
|
|
}
|