summaryrefslogtreecommitdiffstats
path: root/src/World.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-03-20 16:11:50 +0100
committerMattes D <github@xoft.cz>2015-03-20 16:11:50 +0100
commit8a43da07233fd8ab59dca14b8c14668f0651624b (patch)
tree79d0fe2868b9abe1690a813a5930e996e61db15f /src/World.h
parentMerge pull request #1821 from bibo38/bugfix1765 (diff)
parentAdded cPluginLua::cResettable interface, used for scheduled tasks. (diff)
downloadcuberite-8a43da07233fd8ab59dca14b8c14668f0651624b.tar
cuberite-8a43da07233fd8ab59dca14b8c14668f0651624b.tar.gz
cuberite-8a43da07233fd8ab59dca14b8c14668f0651624b.tar.bz2
cuberite-8a43da07233fd8ab59dca14b8c14668f0651624b.tar.lz
cuberite-8a43da07233fd8ab59dca14b8c14668f0651624b.tar.xz
cuberite-8a43da07233fd8ab59dca14b8c14668f0651624b.tar.zst
cuberite-8a43da07233fd8ab59dca14b8c14668f0651624b.zip
Diffstat (limited to 'src/World.h')
-rw-r--r--src/World.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/World.h b/src/World.h
index 0decc8c6e..f7d5cdc60 100644
--- a/src/World.h
+++ b/src/World.h
@@ -106,7 +106,8 @@ public:
virtual void Run(cWorld & a_World) = 0;
} ;
- typedef std::vector<std::unique_ptr<cTask>> cTasks;
+ typedef SharedPtr<cTask> cTaskPtr;
+ typedef std::vector<cTaskPtr> cTasks;
class cTaskSaveAllChunks :
@@ -691,11 +692,10 @@ public:
void QueueSaveAllChunks(void); // tolua_export
/** Queues a task onto the tick thread. The task object will be deleted once the task is finished */
- void QueueTask(std::unique_ptr<cTask> a_Task); // Exported in ManualBindings.cpp
+ void QueueTask(cTaskPtr a_Task); // Exported in ManualBindings.cpp
- /** Queues a task onto the tick thread, with the specified delay.
- The task object will be deleted once the task is finished */
- void ScheduleTask(int a_DelayTicks, cTask * a_Task);
+ /** Queues a task onto the tick thread, with the specified delay. */
+ void ScheduleTask(int a_DelayTicks, cTaskPtr a_Task);
/** Returns the number of chunks loaded */
int GetNumChunks() const; // tolua_export
@@ -867,20 +867,16 @@ private:
{
public:
Int64 m_TargetTick;
- cTask * m_Task;
+ cTaskPtr m_Task;
/** Creates a new scheduled task; takes ownership of the task object passed to it. */
- cScheduledTask(Int64 a_TargetTick, cTask * a_Task) :
+ cScheduledTask(Int64 a_TargetTick, cTaskPtr a_Task) :
m_TargetTick(a_TargetTick),
m_Task(a_Task)
{
}
- virtual ~cScheduledTask()
- {
- delete m_Task;
- m_Task = nullptr;
- }
+ virtual ~cScheduledTask() {}
};
typedef std::unique_ptr<cScheduledTask> cScheduledTaskPtr;