Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Represents a reference to a Lua object that has a tracked lifetime -. More...
#include <LuaState.h>
Public Member Functions | |
void | Clear (void) |
Frees the contained reference, if any. More... | |
cTrackedRef (void) | |
Creates an unbound ref instance. More... | |
bool | IsSameLuaState (cLuaState &a_LuaState) |
Returns true if the reference resides in the specified Lua state. More... | |
bool | IsValid (void) |
Returns true if the contained reference is valid. More... | |
bool | RefStack (cLuaState &a_LuaState, int a_StackPos) |
Set the contained reference to the object at the specified Lua state's stack position. More... | |
~cTrackedRef () | |
Protected Member Functions | |
cTrackedRef (const cTrackedRef &)=delete | |
This class cannot be copied, because it is tracked in the LuaState by-ptr. More... | |
cTrackedRef (cTrackedRef &&)=delete | |
This class cannot be moved, because it is tracked in the LuaState by-ptr. More... | |
cRef & | GetRef () |
Returns the internal reference. More... | |
void | Invalidate (void) |
Invalidates the callback, without untracking it from the cLuaState. More... | |
Protected Attributes | |
std::atomic< cCriticalSection * > | m_CS |
The mutex protecting m_Ref against multithreaded access. More... | |
cRef | m_Ref |
Reference to the Lua callback. More... | |
Friends | |
class | ::cLuaState |
class | cLuaState |
Represents a reference to a Lua object that has a tracked lifetime -.
Definition at line 215 of file LuaState.h.
cLuaState::cTrackedRef::cTrackedRef | ( | void | ) |
Creates an unbound ref instance.
Definition at line 194 of file LuaState.cpp.
|
inline |
Definition at line 222 of file LuaState.h.
|
protecteddelete |
This class cannot be copied, because it is tracked in the LuaState by-ptr.
Use a smart pointer for a copyable object.
|
protecteddelete |
This class cannot be moved, because it is tracked in the LuaState by-ptr.
Use a smart pointer for a copyable object.
void cLuaState::cTrackedRef::Clear | ( | void | ) |
Frees the contained reference, if any.
Untracks the reference from its canon Lua state.
Definition at line 222 of file LuaState.cpp.
|
inlineprotected |
Returns the internal reference.
Only to be used when the cLuaState's CS is held and the cLuaState is known to be valid.
Definition at line 262 of file LuaState.h.
|
protected |
Invalidates the callback, without untracking it from the cLuaState.
Called only from cLuaState when closing the Lua state.
Definition at line 292 of file LuaState.cpp.
bool cLuaState::cTrackedRef::IsSameLuaState | ( | cLuaState & | a_LuaState | ) |
Returns true if the reference resides in the specified Lua state.
Internally, compares the reference's canon Lua state. (Note that depending on this value is not thread-safe, another thread may modify the ref in the meantime. It is meant for quick ASSERTs only).
Definition at line 268 of file LuaState.cpp.
bool cLuaState::cTrackedRef::IsValid | ( | void | ) |
Returns true if the contained reference is valid.
(Note that depending on this value is not thread-safe, another thread may invalidate the ref in the meantime. It is meant for quick ASSERTs only).
Definition at line 253 of file LuaState.cpp.
bool cLuaState::cTrackedRef::RefStack | ( | cLuaState & | a_LuaState, |
int | a_StackPos | ||
) |
Set the contained reference to the object at the specified Lua state's stack position.
If another reference has been previously contained, it is Clear()-ed first.
Definition at line 203 of file LuaState.cpp.
|
friend |
Definition at line 217 of file LuaState.h.
|
friend |
Definition at line 245 of file LuaState.h.
|
protected |
The mutex protecting m_Ref against multithreaded access.
Actually points to the canon Lua state's m_CriticalSection. Is nullptr when ref is empty (not bound).
Definition at line 250 of file LuaState.h.
|
protected |
Reference to the Lua callback.
Definition at line 253 of file LuaState.h.