diff options
author | Mattes D <github@xoft.cz> | 2014-01-15 11:45:25 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-01-15 11:45:25 +0100 |
commit | eb89de4c88ef3c2048af571eaa29726d08148e24 (patch) | |
tree | 783438ae17a67c6953c8170fffcdde8dbf944d50 /src/World.h | |
parent | Merge pull request #538 from mc-server/minecarts (diff) | |
parent | added cWorld::ScheduleTask Function (diff) | |
download | cuberite-eb89de4c88ef3c2048af571eaa29726d08148e24.tar cuberite-eb89de4c88ef3c2048af571eaa29726d08148e24.tar.gz cuberite-eb89de4c88ef3c2048af571eaa29726d08148e24.tar.bz2 cuberite-eb89de4c88ef3c2048af571eaa29726d08148e24.tar.lz cuberite-eb89de4c88ef3c2048af571eaa29726d08148e24.tar.xz cuberite-eb89de4c88ef3c2048af571eaa29726d08148e24.tar.zst cuberite-eb89de4c88ef3c2048af571eaa29726d08148e24.zip |
Diffstat (limited to 'src/World.h')
-rw-r--r-- | src/World.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/World.h b/src/World.h index b61708d03..6ddb3ec86 100644 --- a/src/World.h +++ b/src/World.h @@ -82,7 +82,18 @@ public: virtual void Run(cWorld & a_World) = 0; } ; + /// A common ancestor for all scheduled tasks queued onto the tick thread + class cScheduledTask + { + public: + cScheduledTask(const int a_Ticks) : Ticks(a_Ticks) {}; + virtual ~cScheduledTask() {}; + virtual void Run(cWorld & a_World) = 0; + int Ticks; + }; + typedef std::vector<cTask *> cTasks; + typedef std::list<cScheduledTask *> ScheduledTaskList; class cTaskSaveAllChunks : public cTask @@ -533,6 +544,9 @@ public: /// Queues a task onto the tick thread. The task object will be deleted once the task is finished void QueueTask(cTask * a_Task); // Exported in ManualBindings.cpp + + // Queues a task onto the tick thread. The task object will be deleted once the task is finished + void ScheduleTask(cScheduledTask * a_Task); /// Returns the number of chunks loaded int GetNumChunks() const; // tolua_export @@ -745,9 +759,16 @@ private: /// Guards the m_Tasks cCriticalSection m_CSTasks; + /// Guards the m_ScheduledTasks + cCriticalSection m_CSScheduledTasks; + /// Tasks that have been queued onto the tick thread; guarded by m_CSTasks cTasks m_Tasks; + /// Tasks that have been queued to be executed on the tick thread at some number of ticks in + /// the future; guarded by m_CSScheduledTasks + ScheduledTaskList m_ScheduledTasks; + /// Guards m_Clients cCriticalSection m_CSClients; @@ -775,6 +796,9 @@ private: /// Executes all tasks queued onto the tick thread void TickQueuedTasks(void); + /// Executes all tasks queued onto the tick thread + void TickScheduledTasks(void); + /// Ticks all clients that are in this world void TickClients(float a_Dt); |