summaryrefslogtreecommitdiff
path: root/XSlock.h
blob: 8fb0ce47899bf4f1b6fb631668f1347c2c832661 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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