summaryrefslogtreecommitdiffstats
path: root/src/World.h
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-06-25 16:46:33 +0200
committerworktycho <work.tycho@gmail.com>2015-06-25 16:46:33 +0200
commit7187c003422aae137b1000af04b9bc06c5c4e9d4 (patch)
tree5be1d79c3acddddb0c1c6622c401fa4537735599 /src/World.h
parentMerge pull request #2290 from bibo38/mousefix (diff)
parentButtons no longer click on when already on. Buttons now play sound when clicking off. (diff)
downloadcuberite-7187c003422aae137b1000af04b9bc06c5c4e9d4.tar
cuberite-7187c003422aae137b1000af04b9bc06c5c4e9d4.tar.gz
cuberite-7187c003422aae137b1000af04b9bc06c5c4e9d4.tar.bz2
cuberite-7187c003422aae137b1000af04b9bc06c5c4e9d4.tar.lz
cuberite-7187c003422aae137b1000af04b9bc06c5c4e9d4.tar.xz
cuberite-7187c003422aae137b1000af04b9bc06c5c4e9d4.tar.zst
cuberite-7187c003422aae137b1000af04b9bc06c5c4e9d4.zip
Diffstat (limited to 'src/World.h')
-rw-r--r--src/World.h22
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);