1998-09-09 07:00:04 +00:00
|
|
|
#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;
|
1999-05-02 14:33:17 +00:00
|
|
|
CPerlObj* pPerl;
|
1998-09-09 07:00:04 +00:00
|
|
|
|
|
|
|
class XSLock
|
|
|
|
{
|
|
|
|
public:
|
1999-05-02 14:33:17 +00:00
|
|
|
XSLock(CPerlObj *p) {
|
|
|
|
g_XSLock.Enter();
|
|
|
|
::pPerl = p;
|
|
|
|
};
|
1998-09-09 07:00:04 +00:00
|
|
|
~XSLock() { g_XSLock.Leave(); };
|
|
|
|
};
|
|
|
|
|
1999-05-02 14:33:17 +00:00
|
|
|
/* PERL_CAPI does its own locking in xs_handler() */
|
|
|
|
#if defined(PERL_OBJECT) && !defined(PERL_CAPI)
|
1998-09-09 07:00:04 +00:00
|
|
|
#undef dXSARGS
|
|
|
|
#define dXSARGS \
|
1999-05-02 14:33:17 +00:00
|
|
|
XSLock localLock(pPerl); \
|
|
|
|
dSP; dMARK; \
|
|
|
|
I32 ax = mark - PL_stack_base + 1; \
|
|
|
|
I32 items = sp - mark
|
|
|
|
#endif /* PERL_OBJECT && !PERL_CAPI */
|
1998-09-09 07:00:04 +00:00
|
|
|
|
|
|
|
#endif
|