From 1524f8eb8ca237ad8c02ae348cc8cb60276dbb15 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Tue, 30 Jul 2013 18:25:31 -0700 Subject: Saving some memory by having the LuaTasks being stackless when possible. --- includes/LuaTask.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'includes') diff --git a/includes/LuaTask.h b/includes/LuaTask.h index 1f7a0b5..85ce1f8 100644 --- a/includes/LuaTask.h +++ b/includes/LuaTask.h @@ -3,6 +3,8 @@ #include #include #include +#include +#include namespace Balau { @@ -19,6 +21,7 @@ class LuaExecCell { void throwError() throw (GeneralException); protected: virtual void run(Lua &) = 0; + virtual bool needsStack() { return false; } void setError() { m_gotError = true; } private: Events::Async m_event; @@ -43,6 +46,7 @@ class LuaExecFile : public LuaExecCell { public: LuaExecFile(IO file) : m_file(file) { } private: + virtual bool needsStack() { return !m_file.isA(); } virtual void run(Lua &); IO m_file; }; @@ -52,14 +56,14 @@ class LuaTask : public Task { ~LuaTask() { L.weaken(); } virtual const char * getName() const { return "LuaTask"; } private: - LuaTask(Lua && __L, LuaExecCell * cell) : L(Move(__L)), m_cell(cell) { } + LuaTask(Lua && __L, LuaExecCell * cell) : L(Move(__L)), m_cell(cell) { if (!cell->needsStack()) setStackless(); } virtual void Do(); Lua L; LuaExecCell * m_cell; friend class LuaMainTask; }; -class LuaMainTask : public Task { +class LuaMainTask : public StacklessTask { public: LuaMainTask(); ~LuaMainTask(); -- cgit v1.2.3