uox3/source/cThreadQueue.h
Xoduz 9359970ba0 Added server restart functionality
- [ADD] Added functionality to trigger a server restart from within UOX3, either via console ('R'), command ('restart) or JS Console Method (.BeginRestart()). This will first perform a world save, then do a clean shut down before restarting UOX3 in a new process
2025-10-24 16:13:17 +08:00

52 lines
1.2 KiB
C++

#ifndef __CTHREADQUEUE_H__
#define __CTHREADQUEUE_H__
#include <string>
#include <queue>
#include <mutex>
//o------------------------------------------------------------------------------------------------o
enum MessageType
{
MSG_WORLDSAVE = 0,
MSG_SHUTDOWN,
MSG_UNKNOWN,
MSG_PRINT,
MSG_RELOADJS,
MSG_CONSOLEBCAST,
MSG_PRINTDONE,
MSG_PRINTFAILED,
MSG_SECTIONBEGIN,
MSG_RELOAD,
MSG_RESTART,
MSG_COUNT
};
struct MessagePassed_st
{
MessageType actualMessage;
std::string data;
};
//o------------------------------------------------------------------------------------------------o
class CThreadQueue
{
private:
std::queue<MessagePassed_st> internalQueue;
std::mutex queuelock;
public:
CThreadQueue() = default;
auto NewMessage( MessageType toAdd, const std::string& data = "" ) -> void;
auto GrabMessage()->MessagePassed_st;
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_st>;
};
extern CThreadQueue messageLoop;
#endif