Enabled LOCK/UNLOCK macros.

This commit is contained in:
kin%netscape.com 1999-06-03 15:26:48 +00:00
parent 3a09e85b99
commit 236417d08b
3 changed files with 50 additions and 10 deletions

View File

@ -43,9 +43,6 @@ LINCS=-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\base \
-I$(PUBLIC)\raptor
LLIBS= \
$(DIST)\lib\xpcom.lib
MAKE_OBJ_TYPE = DLL
DLLNAME = txmgr
DLL=.\$(OBJDIR)\$(DLLNAME).dll
@ -59,7 +56,10 @@ LCFLAGS = \
$(NULL)
# These are the libraries we need to link with to create the dll
LLIBS=$(DIST)\lib\xpcom.lib
LLIBS = \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(NULL)
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib

View File

@ -27,8 +27,8 @@
#include "nsCOMPtr.h"
#define LOCK_TX_MANAGER(mgr)
#define UNLOCK_TX_MANAGER(mgr)
#define LOCK_TX_MANAGER(mgr) (mgr)->Lock()
#define UNLOCK_TX_MANAGER(mgr) (mgr)->Unlock()
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITransactionManagerIID, NS_ITRANSACTIONMANAGER_IID);
@ -37,6 +37,8 @@ nsTransactionManager::nsTransactionManager(PRInt32 aMaxTransactionCount)
: mMaxTransactionCount(aMaxTransactionCount), mListeners(0)
{
mRefCnt = 0;
mMonitor = ::PR_NewMonitor();
}
nsTransactionManager::~nsTransactionManager()
@ -55,6 +57,12 @@ nsTransactionManager::~nsTransactionManager()
delete mListeners;
mListeners = 0;
}
if (mMonitor)
{
::PR_DestroyMonitor(mMonitor);
mMonitor = 0;
}
}
#ifdef DEBUG_TXMGR_REFCNT
@ -652,8 +660,13 @@ nsTransactionManager::RemoveListener(nsITransactionListener *aListener)
if (!mListeners)
return NS_ERROR_FAILURE;
LOCK_TX_MANAGER(this);
if (!mListeners->RemoveElement((void *)aListener))
{
UNLOCK_TX_MANAGER(this);
return NS_ERROR_FAILURE;
}
NS_IF_RELEASE(aListener);
@ -663,6 +676,8 @@ nsTransactionManager::RemoveListener(nsITransactionListener *aListener)
mListeners = 0;
}
UNLOCK_TX_MANAGER(this);
return NS_OK;
}
@ -1127,14 +1142,15 @@ nsTransactionManager::EndTransaction()
if (result != NS_COMFALSE) {
result = topTransaction->Merge(&didMerge, tint);
nsresult result2 = DidMergeNotify(topTransaction, tint, didMerge, result);
if (NS_SUCCEEDED(result))
result = result2;
if (NS_FAILED(result)) {
// XXX: What do we do if this fails?
}
nsresult result2 = DidMergeNotify(topTransaction, tint, didMerge, result);
// XXX: What do we do if this fails?
if (didMerge) {
delete tx;
return result;
@ -1173,3 +1189,21 @@ nsTransactionManager::EndTransaction()
return result;
}
nsresult
nsTransactionManager::Lock()
{
if (mMonitor)
PR_EnterMonitor(mMonitor);
return NS_OK;
}
nsresult
nsTransactionManager::Unlock()
{
if (mMonitor)
PR_ExitMonitor(mMonitor);
return NS_OK;
}

View File

@ -19,6 +19,8 @@
#ifndef nsTransactionManager_h__
#define nsTransactionManager_h__
#include "prmon.h"
class nsITransaction;
class nsITransactionManager;
class nsITransactionListener;
@ -40,6 +42,8 @@ private:
nsTransactionRedoStack mRedoStack;
nsVoidArray *mListeners;
PRMonitor *mMonitor;
public:
/** The default constructor.
@ -95,6 +99,8 @@ private:
/* nsTransactionManager specific private methods. */
virtual nsresult BeginTransaction(nsITransaction *aTransaction);
virtual nsresult EndTransaction(void);
virtual nsresult Lock(void);
virtual nsresult Unlock(void);
};
#endif // nsTransactionManager_h__