summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-02-10 20:38:02 +0100
committermadmaxoft <github@xoft.cz>2014-02-10 20:38:02 +0100
commit5aa1123f70303316b13b4a1377b4e970cd2bc707 (patch)
treeb7da6c280ce83c87d2aaf7893ba0300aff11fbf0 /src
parentDebuggers: Added a cLuaChunkStay test code. (diff)
downloadcuberite-5aa1123f70303316b13b4a1377b4e970cd2bc707.tar
cuberite-5aa1123f70303316b13b4a1377b4e970cd2bc707.tar.gz
cuberite-5aa1123f70303316b13b4a1377b4e970cd2bc707.tar.bz2
cuberite-5aa1123f70303316b13b4a1377b4e970cd2bc707.tar.lz
cuberite-5aa1123f70303316b13b4a1377b4e970cd2bc707.tar.xz
cuberite-5aa1123f70303316b13b4a1377b4e970cd2bc707.tar.zst
cuberite-5aa1123f70303316b13b4a1377b4e970cd2bc707.zip
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/PluginLua.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index ad0cfbe5a..a177f5288 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -35,7 +35,33 @@ class cPluginLua :
public:
// tolua_end
- cPluginLua( const AString & a_PluginDirectory );
+ /** A RAII-style mutex lock for accessing the internal LuaState.
+ This will be the only way to retrieve the plugin's LuaState;
+ therefore it directly supports accessing the LuaState of the locked plugin.
+ Usage:
+ cPluginLua::cOperation Op(SomePlugin);
+ Op().Call(...) // Call a function in the plugin's LuaState
+ */
+ class cOperation
+ {
+ public:
+ cOperation(cPluginLua & a_Plugin) :
+ m_Plugin(a_Plugin),
+ m_Lock(a_Plugin.m_CriticalSection)
+ {
+ }
+
+ cLuaState & operator ()(void) { return m_Plugin.m_LuaState; }
+
+ protected:
+ cPluginLua & m_Plugin;
+
+ /** RAII lock for m_Plugin.m_CriticalSection */
+ cCSLock m_Lock;
+ } ;
+
+
+ cPluginLua(const AString & a_PluginDirectory);
~cPluginLua();
virtual void OnDisable(void) override;