summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginLua.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-02-11 09:07:08 +0100
committerMattes D <github@xoft.cz>2014-02-11 09:07:08 +0100
commit1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e (patch)
tree0cacd6ad93e9d02c0228bc314834bd7e8edae1bc /src/Bindings/PluginLua.h
parentMerge pull request #660 from worktycho/boatsFix (diff)
parentDebuggers: Updated messaging functions (diff)
downloadcuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.gz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.bz2
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.lz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.xz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.zst
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.zip
Diffstat (limited to 'src/Bindings/PluginLua.h')
-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;