summaryrefslogtreecommitdiffstats
path: root/contrib/perl5/XSlock.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/perl5/XSlock.h')
-rw-r--r--contrib/perl5/XSlock.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/perl5/XSlock.h b/contrib/perl5/XSlock.h
new file mode 100644
index 0000000..8fb0ce4
--- /dev/null
+++ b/contrib/perl5/XSlock.h
@@ -0,0 +1,35 @@
+#ifndef __XSlock_h__
+#define __XSlock_h__
+
+class XSLockManager
+{
+public:
+ XSLockManager() { InitializeCriticalSection(&cs); };
+ ~XSLockManager() { DeleteCriticalSection(&cs); };
+ void Enter(void) { EnterCriticalSection(&cs); };
+ void Leave(void) { LeaveCriticalSection(&cs); };
+protected:
+ CRITICAL_SECTION cs;
+};
+
+XSLockManager g_XSLock;
+
+class XSLock
+{
+public:
+ XSLock() { g_XSLock.Enter(); };
+ ~XSLock() { g_XSLock.Leave(); };
+};
+
+CPerlObj* pPerl;
+
+#undef dXSARGS
+#define dXSARGS \
+ dSP; dMARK; \
+ I32 ax = mark - PL_stack_base + 1; \
+ I32 items = sp - mark; \
+ XSLock localLock; \
+ ::pPerl = pPerl
+
+
+#endif
OpenPOWER on IntegriCloud