/** * Create a LuaThread around a function and environment * @param func The function to execute */ public LuaThread(Globals globals, LuaValue func) { LuaValue.assert_(func != null, "function cannot be null"); state = new State(globals, this, func); this.globals = globals; }
public Varargs resume(Varargs args) { final LuaThread.State s = this.state; if (s.status > LuaThread.STATUS_SUSPENDED) return LuaValue.varargsOf(LuaValue.FALSE, LuaValue.valueOf("cannot resume "+(s.status==LuaThread.STATUS_DEAD? "dead": "non-suspended")+" coroutine")); return s.lua_resume(this, args); }
/** Function which yields the current thread. * @param args Arguments to supply as return values in the resume function of the resuming thread. * @return Values supplied as arguments to the resume() call that reactivates this thread. */ public Varargs yield(Varargs args) { if (running == null || running.isMainThread()) throw new LuaError("cannot yield main thread"); final LuaThread.State s = running.state; return s.lua_yield(args); }
/** Private constructor for main thread only */ public LuaThread(Globals globals) { state = new State(globals, this, null); state.status = STATUS_RUNNING; this.globals = globals; }
/** * Create a LuaThread around a function and environment * @param func The function to execute */ public LuaThread(Globals globals, LuaValue func) { LuaValue.assert_(func != null, "function cannot be null"); state = new State(globals, this, func); this.globals = globals; }
/** Private constructor for main thread only */ public LuaThread(Globals globals) { state = new State(globals, this, null); state.status = STATUS_RUNNING; this.globals = globals; }
/** * Create a LuaThread around a function and environment * @param func The function to execute */ public LuaThread(Globals globals, LuaValue func) { LuaValue.assert_(func != null, "function cannot be null"); state = new State(globals, this, func); this.globals = globals; }
/** Function which yields the current thread. * @param args Arguments to supply as return values in the resume function of the resuming thread. * @return Values supplied as arguments to the resume() call that reactivates this thread. */ public Varargs yield(Varargs args) { if (running == null || running.isMainThread()) throw new LuaError("cannot yield main thread"); final LuaThread.State s = running.state; return s.lua_yield(args); }
public Varargs resume(Varargs args) { final LuaThread.State s = this.state; if (s.status > LuaThread.STATUS_SUSPENDED) return LuaValue.varargsOf(LuaValue.FALSE, LuaValue.valueOf("cannot resume "+(s.status==LuaThread.STATUS_DEAD? "dead": "non-suspended")+" coroutine")); return s.lua_resume(this, args); }
/** Private constructor for main thread only */ public LuaThread(Globals globals) { state = new State(globals, this, null); state.status = STATUS_RUNNING; this.globals = globals; }