org.luaj.vm2
Class LuaThread

java.lang.Object
  extended by org.luaj.vm2.Varargs
      extended by org.luaj.vm2.LuaValue
          extended by org.luaj.vm2.LuaThread
All Implemented Interfaces:
java.lang.Runnable

public class LuaThread
extends LuaValue
implements java.lang.Runnable

Implementation of lua coroutines using Java Threads


Field Summary
 int calls
           
 LuaFunction[] callstack
           
 java.lang.Object debugState
           
 LuaValue err
           
static int MAX_CALLSTACK
           
static LuaValue s_metatable
           
 
Fields inherited from class org.luaj.vm2.LuaValue
CALL, EMPTYSTRING, FALSE, INDEX, METATABLE, MINUSONE, MODE, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, ZERO
 
Constructor Summary
LuaThread(LuaValue func, LuaValue env)
           
 
Method Summary
 LuaThread checkthread()
           
static int getCallstackDepth()
           
static LuaFunction getCallstackFunction(int level)
          Get the function called as a specific location on the stack.
 LuaValue getfenv()
           
static LuaValue getGlobals()
          Get the current thread's environment
 LuaValue getmetatable()
           
static LuaThread getRunning()
           
 java.lang.String getStatus()
           
static boolean isMainThread(LuaThread r)
           
 boolean isthread()
           
static void onCall(LuaFunction function)
           
static void onReturn()
           
 LuaThread optthread(LuaThread defval)
           
 Varargs resume(Varargs args)
          Start or resume this thread
 void run()
           
 void setfenv(LuaValue env)
           
static void setGlobals(LuaValue globals)
          Set the globals of the current thread
 int type()
           
 java.lang.String typename()
           
 Varargs yield(Varargs args)
           
 
Methods inherited from class org.luaj.vm2.LuaValue
add, add, add, and, arg, arg1, argerror, argerror, aritherror, aritherror, assert_, call, call, call, call, callerror, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checknumber, checkstring, checkString, checktable, checkuserdata, checkuserdata, checkvalidkey, compareerror, compareerror, concat_s, concat, concatTo_s, div, divInto, eq_b, eq_b, eq_b, eq_b, eq, equals, error, get, get, get, getn, gettable, gt_b, gt_b, gt_b, gt, gteq_b, gteq_b, gteq_b, gteq, incr, inext, invoke, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isint, isinttype, islong, isnil, isnumber, isstring, istable, isuserdata, isuserdata, len, lenerror, length, listOf, listOf, load, lt_b, lt_b, lt_b, lt, lteq_b, lteq_b, lteq_b, lteq, metatag, method, method, method, method, method, method, mod, modFrom, mul, mul, mul, narg, neg, neq_b, neq_b, neq_b, neq, next, not, onInvoke, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, optString, opttable, optuserdata, optuserdata, optvalue, or, pow, powWith, powWith, presize, rawget, rawget, rawget, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setmetatable, settable, strcmp, strcmp, strongvalue, strvalue, sub, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, testfor_b, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, tonumber, toshort, tostring, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf
 
Methods inherited from class org.luaj.vm2.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checkString, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, optString, opttable, optthread, optuserdata, optuserdata, optvalue, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

s_metatable

public static LuaValue s_metatable

err

public LuaValue err

MAX_CALLSTACK

public static final int MAX_CALLSTACK
See Also:
Constant Field Values

callstack

public final LuaFunction[] callstack

calls

public int calls

debugState

public java.lang.Object debugState
Constructor Detail

LuaThread

public LuaThread(LuaValue func,
                 LuaValue env)
Method Detail

type

public int type()
Specified by:
type in class LuaValue

typename

public java.lang.String typename()
Specified by:
typename in class LuaValue

isthread

public boolean isthread()
Overrides:
isthread in class LuaValue

optthread

public LuaThread optthread(LuaThread defval)
Overrides:
optthread in class LuaValue

checkthread

public LuaThread checkthread()
Overrides:
checkthread in class LuaValue

getmetatable

public LuaValue getmetatable()
Overrides:
getmetatable in class LuaValue

getfenv

public LuaValue getfenv()
Overrides:
getfenv in class LuaValue

setfenv

public void setfenv(LuaValue env)
Overrides:
setfenv in class LuaValue

getStatus

public java.lang.String getStatus()

getRunning

public static LuaThread getRunning()

isMainThread

public static boolean isMainThread(LuaThread r)

setGlobals

public static void setGlobals(LuaValue globals)
Set the globals of the current thread


getGlobals

public static LuaValue getGlobals()
Get the current thread's environment


onCall

public static final void onCall(LuaFunction function)

onReturn

public static final void onReturn()

getCallstackDepth

public static int getCallstackDepth()

getCallstackFunction

public static final LuaFunction getCallstackFunction(int level)
Get the function called as a specific location on the stack.

Parameters:
level - 1 for the function calling this one, 2 for the next one.
Returns:
LuaFunction on the call stack, or null if outside of range of active stack

run

public void run()
Specified by:
run in interface java.lang.Runnable

yield

public Varargs yield(Varargs args)

resume

public Varargs resume(Varargs args)
Start or resume this thread



Copyright © 2007-2013 Luaj.org. All Rights Reserved.