ZFFramework
 
Loading...
Searching...
No Matches
ZFLuaState.h File Reference

native lua state impl More...

#include "ZFLuaDef.h"

Go to the source code of this file.

Namespaces

namespace  ZFGlobalEvent
 

 

Functions

void * ZFLuaState ()
 return lua state for current thread, auto create and attach if no state attached to current thread
 
void * ZFLuaStateCheck ()
 try get lua state for current thread, or return null if none
 
void ZFLuaStateChange (void *L)
 change builtin lua state for current thread, see ZFLuaState
 
ZFCoreArray< void * > ZFLuaStateList ()
 get lua state list for current thread, see ZFLuaState
 
void ZFLuaStateListForAllThread (ZFCoreArray< void * > &luaStateList, ZFCoreArray< ZFThread * > &threadList)
 get lua state list for all thread, use with caution, see ZFLuaState
 
void * ZFLuaStateOpen ()
 create new lua state, see ZFLuaState
 
void ZFLuaStateClose (void *L)
 close lua state, see ZFLuaState
 
void ZFLuaStateAttach (void *L)
 attach existing lua state to current thread, see ZFLuaState
 
void ZFLuaStateDetach (void *L)
 detach lua state from current thread, see ZFLuaState
 
zfidentity ZFGlobalEvent::E_LuaStateOnAttach (void)
 see ZFObject::observerNotify
 
zfidentity ZFGlobalEvent::E_LuaStateOnDetach (void)
 see ZFObject::observerNotify
 

Detailed Description

native lua state impl

Function Documentation

◆ ZFLuaState()

void * ZFLuaState ( )
extern

return lua state for current thread, auto create and attach if no state attached to current thread

ZFFramework can be used in any native lua state (by using ZFLuaExecute), but only if you have attached them by ZFLuaStateAttach
note that, lua is not thread safe, ZFFramework maintains lua states for each native ZFThread, these lua state is completely separate from each other, no global data or data sharing available, you must supply global methods in cpp to share data between threads

by default, ZFLuaState would automatically create a thread local lua state for current thread (create new if not exist, you may change it by ZFLuaStateChange), you may still attach your own lua state for same thread by ZFLuaStateAttach, and obtain by ZFLuaStateList for current thread, or ZFLuaStateListForAllThread for all thread

◆ ZFLuaStateCheck()

void * ZFLuaStateCheck ( )
extern

try get lua state for current thread, or return null if none

See also
ZFLuaState