diff options
author | pixel <pixel> | 2006-02-09 17:08:24 +0000 |
---|---|---|
committer | pixel <pixel> | 2006-02-09 17:08:24 +0000 |
commit | 1f97ba72e51f52f351137550239e9dae7f743fc7 (patch) | |
tree | 6d3108a06b884e5092fcce5c6d287af547e5daef /include | |
parent | 038c92026a1222d204dcf1b85e5f349eb24f34d5 (diff) |
In general: better thread handling. Added locks everywhere it should. Added/fixed thread spawning stuff.
Also, added Lua's methods:
-) copy
-) setgcthreshold
-) getgcthreshold
-) getgccount
Diffstat (limited to 'include')
-rw-r--r-- | include/BLua.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/include/BLua.h b/include/BLua.h index 77c3a9d..9fa4248 100644 --- a/include/BLua.h +++ b/include/BLua.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: BLua.h,v 1.27 2006-01-31 17:02:38 pixel Exp $ */ +/* $Id: BLua.h,v 1.28 2006-02-09 17:08:24 pixel Exp $ */ #ifndef __BLUA_H__ #define __BLUA_H__ @@ -33,6 +33,7 @@ extern "C" { #define lua_unlock(L) do_lua_unlock(L) #include <lua.h> +#include <lauxlib.h> #include <map> #include <Exceptions.h> #include <Handle.h> @@ -66,6 +67,7 @@ class Lua : public Base { void push(void *); void push(lua_CFunction, int = 0); void pop(int = 1); + void copy(int = -1); void newtable(); void * newuser(size_t); void settable(int = -3, bool raw = false); @@ -94,11 +96,16 @@ class Lua : public Base { Lua * tothread(int = -1); String escape_string(const String &); void load(Handle *, bool docall = true) throw (GeneralException); + void load(const String &, bool docall = true) throw (GeneralException); void dump(Handle *, bool strip = true); void dumpvars(Handle *, const String &, int = -1); - Lua * thread(); - int yield(int nargs = 0); - int resume(int nresults = 0); + Lua * thread(bool saveit = true); + Lua * thread(const String &, int nargs = 0, bool saveit = true); + Lua * thread(Handle *, int nargs = 0, bool saveit = true); + int yield(int nresults = 0); + void resume(int nargs = 0) throw (GeneralException); + void resume(const String &, int nargs = 0); + void resume(Handle *, int nargs = 0); static Lua * find(lua_State *) throw (GeneralException); void showerror(); int getmetatable(int = -1); @@ -107,16 +114,28 @@ class Lua : public Base { void do_break(); - virtual void lock() {} - virtual void unlock() {} + virtual void lock(); + virtual void unlock(); bool is_protected(); - private: + void openlib(const String & libname, const struct luaL_reg *l, int nup); + + void setgcthreshold(int = 0); + int getgcthreshold(); + int getgccount(); + + protected: + virtual Lua * spawn_from_thread(lua_State *); Lua(lua_State *); + + private: + void setup_state(lua_State *); lua_State * L; static std::map<lua_State *, Lua *> lualist; - bool _protected; + bool _protected, _is_thread; void dumpvars_r(Handle *, int, int = 0) throw (GeneralException); + + friend class LuaStatics; }; class LuaObject : public Base { |