/// <summary> /// Returns a script state for the connection. /// </summary> /// <param name="conn"></param> /// <returns></returns> public ScriptState CreateScriptState(ChannelConnection conn) { var NL = Melua.lua_newthread(GL); var state = new ScriptState(conn, NL); lock (_states) _states.Add(NL, state); return(state); }
/// <summary> /// Creates new Lua thread for the state to use and saves /// a reference to the connection's script state. /// </summary> /// <param name="conn"></param> /// <returns></returns> public LuaThread GetNewThread(ScriptState state) { if (state.LuaThread != null) { this.RemoveThread(state.LuaThread); } IntPtr NL; int index; lock (_glSyncLock) { // Create new thread and save index, so it can be removed later. NL = Melua.lua_newthread(GL); index = Melua.lua_gettop(GL); } lock (_states) _states.Add(NL, state); return(new LuaThread(NL, index)); }