summaryrefslogtreecommitdiffstats
path: root/src/Server.h
diff options
context:
space:
mode:
authorFeyo Korenhof <35343640+feyokorenhof@users.noreply.github.com>2021-05-26 18:07:32 +0200
committerGitHub <noreply@github.com>2021-05-26 18:07:32 +0200
commit9ddc3635d6a04ff4b78611df00c905cc86e166ae (patch)
treefa6da8cea0a2f0c9c05bb9ffa1880e25a911c6b8 /src/Server.h
parentRe-implement up/down placement metadata (#5219) (diff)
downloadcuberite-9ddc3635d6a04ff4b78611df00c905cc86e166ae.tar
cuberite-9ddc3635d6a04ff4b78611df00c905cc86e166ae.tar.gz
cuberite-9ddc3635d6a04ff4b78611df00c905cc86e166ae.tar.bz2
cuberite-9ddc3635d6a04ff4b78611df00c905cc86e166ae.tar.lz
cuberite-9ddc3635d6a04ff4b78611df00c905cc86e166ae.tar.xz
cuberite-9ddc3635d6a04ff4b78611df00c905cc86e166ae.tar.zst
cuberite-9ddc3635d6a04ff4b78611df00c905cc86e166ae.zip
Diffstat (limited to 'src/Server.h')
-rw-r--r--src/Server.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Server.h b/src/Server.h
index 3d272d7c0..7701faa69 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -105,6 +105,9 @@ public:
The command's output will be written to the a_Output callback. */
void QueueExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output);
+ /** Queues a lambda task onto the server tick thread, with the specified delay in ticks. */
+ void ScheduleTask(cTickTime a_DelayTicks, std::function<void(class cServer &)> a_Task);
+
/** Lists all available console commands and their helpstrings */
void PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & a_Output);
@@ -245,6 +248,18 @@ private:
AStringVector m_Ports;
+ /** Time, in ticks, since the server started
+ Not persistent across server restarts */
+ cTickTimeLong m_UpTime;
+
+ /** Guards the m_Tasks */
+ cCriticalSection m_CSTasks;
+
+ /** Tasks that have been queued onto the tick thread, possibly to be
+ executed at target tick in the future; guarded by m_CSTasks */
+ std::vector<std::pair<std::chrono::milliseconds, std::function<void(class cServer &)>>> m_Tasks;
+
+
cServer(void);
/** Executes the console command, sends output through the specified callback. */
@@ -268,6 +283,11 @@ private:
/** Executes commands queued in the command queue. */
void TickCommands(void);
+
+ /** Executes all tasks queued onto the tick thread */
+ void TickQueuedTasks(void);
+
+
}; // tolua_export