summaryrefslogtreecommitdiffstats
path: root/src/World.h
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-01-14 21:17:03 +0100
committerTycho <work.tycho+git@gmail.com>2014-01-14 21:17:03 +0100
commit292ccdc09e083d6c0af02328651ef3d99cd8edb6 (patch)
tree3300fbe00f3b8fdca7dccb9a912bf79a1a841f2e /src/World.h
parentCMake: Release profile build inherits from Release, not Debug. (diff)
downloadcuberite-292ccdc09e083d6c0af02328651ef3d99cd8edb6.tar
cuberite-292ccdc09e083d6c0af02328651ef3d99cd8edb6.tar.gz
cuberite-292ccdc09e083d6c0af02328651ef3d99cd8edb6.tar.bz2
cuberite-292ccdc09e083d6c0af02328651ef3d99cd8edb6.tar.lz
cuberite-292ccdc09e083d6c0af02328651ef3d99cd8edb6.tar.xz
cuberite-292ccdc09e083d6c0af02328651ef3d99cd8edb6.tar.zst
cuberite-292ccdc09e083d6c0af02328651ef3d99cd8edb6.zip
Diffstat (limited to '')
-rw-r--r--src/World.h24
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);