diff options
author | Hax52 <jay.bourgeois7@gmail.com> | 2015-06-23 04:00:15 +0200 |
---|---|---|
committer | hax52 <jay.bourgeois7@gmail.com> | 2015-06-24 20:52:56 +0200 |
commit | 9f1d1c058fa5fe415a264be710d774dc37e12f5e (patch) | |
tree | 45298832af28e55e24239e3821ca72730440ecd8 /src/World.h | |
parent | Merge pull request #2274 from cuberite/ItemsRemovalFix (diff) | |
download | cuberite-9f1d1c058fa5fe415a264be710d774dc37e12f5e.tar cuberite-9f1d1c058fa5fe415a264be710d774dc37e12f5e.tar.gz cuberite-9f1d1c058fa5fe415a264be710d774dc37e12f5e.tar.bz2 cuberite-9f1d1c058fa5fe415a264be710d774dc37e12f5e.tar.lz cuberite-9f1d1c058fa5fe415a264be710d774dc37e12f5e.tar.xz cuberite-9f1d1c058fa5fe415a264be710d774dc37e12f5e.tar.zst cuberite-9f1d1c058fa5fe415a264be710d774dc37e12f5e.zip |
Diffstat (limited to '')
-rw-r--r-- | src/World.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/World.h b/src/World.h index 064b50165..2ea89f338 100644 --- a/src/World.h +++ b/src/World.h @@ -103,8 +103,12 @@ public: class cTask { public: + cTask(const cTask & other) = default; virtual ~cTask() {} virtual void Run(cWorld & a_World) = 0; + + protected: + cTask() {} } ; typedef SharedPtr<cTask> cTaskPtr; @@ -142,6 +146,21 @@ public: std::vector<Vector3i> m_SendQueue; }; + class cTaskLambda : + public cTask + { + + public: + cTaskLambda(std::function<void(cWorld&)> a_Func) : + m_func(a_Func) + { } + + protected: + virtual void Run(cWorld & a_World) override; + + std::function<void(cWorld&)> m_func; + }; + static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates { @@ -705,6 +724,9 @@ public: /** Queues a task onto the tick thread. The task object will be deleted once the task is finished */ void QueueTask(cTaskPtr a_Task); // Exported in ManualBindings.cpp + /** Queues a lambda task onto the tick thread, with the specified delay. */ + void ScheduleTask(int a_DelayTicks, std::function<void(cWorld&)> a_Func); + /** Queues a task onto the tick thread, with the specified delay. */ void ScheduleTask(int a_DelayTicks, cTaskPtr a_Task); |