Cuberite
A lightweight, fast and extensible game server for Minecraft
Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
cCanonLuaStates Class Reference

Tracks the canon cLuaState instances for each lua_State pointer. More...

Collaboration diagram for cCanonLuaStates:
Collaboration graph
[legend]

Static Public Member Functions

static void Add (cLuaState &a_LuaState)
 Adds a new canon cLuaState instance to the map. More...
 
static cLuaStateGetCanonState (lua_State *a_LuaState)
 Returns the canon Lua state for the specified lua_State pointer. More...
 
static void Remove (cLuaState &a_LuaState)
 Removes the bindings between the specified canon state and its lua_State pointer. More...
 

Static Protected Member Functions

static cCanonLuaStatesGetInstance (void)
 Returns the singleton instance of this class. More...
 

Protected Attributes

std::map< lua_State *, cLuaState * > m_CanonStates
 Map of lua_State pointers to their canon cLuaState instances. More...
 
cCriticalSection m_CS
 The mutex protecting m_CanonStates against multithreaded access. More...
 

Detailed Description

Tracks the canon cLuaState instances for each lua_State pointer.

Used for tracked refs - the ref needs to be tracked by a single cLuaState (the canon state), despite being created from a different (attached) cLuaState. The canon state must be available without accessing the Lua state itself (so it cannot be stored within Lua).

Definition at line 63 of file LuaState.cpp.

Member Function Documentation

◆ Add()

static void cCanonLuaStates::Add ( cLuaState a_LuaState)
inlinestatic

Adds a new canon cLuaState instance to the map.

Used when a new Lua state is created, this informs the map that a new canon Lua state should be tracked.

Definition at line 81 of file LuaState.cpp.

◆ GetCanonState()

static cLuaState* cCanonLuaStates::GetCanonState ( lua_State *  a_LuaState)
inlinestatic

Returns the canon Lua state for the specified lua_State pointer.

Definition at line 67 of file LuaState.cpp.

◆ GetInstance()

static cCanonLuaStates& cCanonLuaStates::GetInstance ( void  )
inlinestaticprotected

Returns the singleton instance of this class.

Definition at line 109 of file LuaState.cpp.

◆ Remove()

static void cCanonLuaStates::Remove ( cLuaState a_LuaState)
inlinestatic

Removes the bindings between the specified canon state and its lua_State pointer.

Used when a Lua state is being closed.

Definition at line 91 of file LuaState.cpp.

Member Data Documentation

◆ m_CanonStates

std::map<lua_State *, cLuaState *> cCanonLuaStates::m_CanonStates
protected

Map of lua_State pointers to their canon cLuaState instances.

Definition at line 105 of file LuaState.cpp.

◆ m_CS

cCriticalSection cCanonLuaStates::m_CS
protected

The mutex protecting m_CanonStates against multithreaded access.

Definition at line 102 of file LuaState.cpp.


The documentation for this class was generated from the following file: