mirror of
https://github.com/UOX3DevTeam/UOX3
synced 2026-08-13 12:27:04 -04:00
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#ifndef __CTHREADQUEUE_H__
|
|
#define __CTHREADQUEUE_H__
|
|
|
|
#include <string>
|
|
#include <queue>
|
|
#include <mutex>
|
|
|
|
//==============================================================================
|
|
enum MessageType {
|
|
MSG_WORLDSAVE = 0,
|
|
MSG_SHUTDOWN,
|
|
MSG_UNKNOWN,
|
|
MSG_PRINT,
|
|
MSG_RELOADJS,
|
|
MSG_CONSOLEBCAST,
|
|
MSG_PRINTDONE,
|
|
MSG_PRINTFAILED,
|
|
MSG_SECTIONBEGIN,
|
|
MSG_RELOAD,
|
|
MSG_COUNT
|
|
};
|
|
|
|
struct MessagePassed {
|
|
MessageType actualMessage;
|
|
std::string data;
|
|
};
|
|
|
|
//==============================================================================
|
|
class CThreadQueue {
|
|
private:
|
|
std::queue< MessagePassed > internalQueue;
|
|
std::mutex queuelock;
|
|
public:
|
|
CThreadQueue() = default;
|
|
auto NewMessage( MessageType toAdd, const std::string& data="" ) ->void;
|
|
auto GrabMessage()->MessagePassed ;
|
|
auto Empty()->bool;
|
|
auto operator<<( MessageType newMessage )->CThreadQueue & ;
|
|
auto operator<<( char *toPush )->CThreadQueue & ;
|
|
auto operator<<( const char *toPush )->CThreadQueue &;
|
|
auto operator<<( const std::string& toPush )->CThreadQueue &;
|
|
auto bulkData() ->std::queue<MessagePassed> ;
|
|
};
|
|
|
|
extern CThreadQueue messageLoop;
|
|
|
|
#endif
|
|
|