Removal of calls to PR_MumbleMonitor, which were way too heavy-handed for the job. Replaced with PR_AtomicInc/Decrement. part of module sweep, r=morse, pavlov

This commit is contained in:
sfraser%netscape.com 1999-10-21 05:36:21 +00:00
Родитель 6fac85ea8a
Коммит f53c9c41ba
6 изменённых файлов: 16 добавлений и 48 удалений

Просмотреть файл

@ -16,6 +16,8 @@
* Reserved.
*/
#include "pratom.h"
#include "nsVoidArray.h"
#include "nsIDOMDocument.h"
@ -155,9 +157,8 @@ nsEditor::nsEditor()
{
//initialize member variables here
NS_INIT_REFCNT();
PR_EnterMonitor(GetEditorMonitor());
gInstanceCount++;
PR_ExitMonitor(GetEditorMonitor());
PR_AtomicIncrement(&gInstanceCount);
}
nsEditor::~nsEditor()
@ -184,6 +185,8 @@ nsEditor::~nsEditor()
InsertTextTxn::ClassShutdown();
IMETextTxn::ClassShutdown();
IMECommitTxn::ClassShutdown();
PR_AtomicDecrement(&gInstanceCount);
}

Просмотреть файл

@ -21,7 +21,6 @@
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
#include "prmon.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
@ -66,9 +65,6 @@ class AddStyleSheetTxn;
class RemoveStyleSheetTxn;
class nsFileSpec;
//This is the monitor for the editor.
PRMonitor *GetEditorMonitor();
/** implementation of an editor object. it will be the controler/focal point
* for the main editor services. i.e. the GUIManager, publishing, transaction

Просмотреть файл

@ -304,6 +304,8 @@ nsEditorModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
if (!okToUnload) {
return NS_ERROR_INVALID_POINTER;
}
// we might want to check nsEditor::gInstanceCount == 0 and count
// factory locks here one day.
*okToUnload = PR_FALSE;
return NS_ERROR_FAILURE;
}
@ -336,20 +338,3 @@ extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
gModule = m; // WARNING: Weak Reference
return rv;
}
//!!!!!! This is obsolete is needs to be removed. It should be removed after the calls to
//!!!!!! it are removed.
//if more than one person asks for the monitor at the same time for the FIRST time, we are screwed
PRMonitor *GetEditorMonitor()
{
static PRMonitor *ns_editlock = nsnull;
if (nsnull == ns_editlock)
{
ns_editlock = (PRMonitor *)1; //how long will the next line take? lets cut down on the chance of reentrancy
ns_editlock = PR_NewMonitor();
}
else if ((PRMonitor *)1 == ns_editlock)
return GetEditorMonitor();
return ns_editlock;
}

Просмотреть файл

@ -16,6 +16,8 @@
* Reserved.
*/
#include "pratom.h"
#include "nsVoidArray.h"
#include "nsIDOMDocument.h"
@ -155,9 +157,8 @@ nsEditor::nsEditor()
{
//initialize member variables here
NS_INIT_REFCNT();
PR_EnterMonitor(GetEditorMonitor());
gInstanceCount++;
PR_ExitMonitor(GetEditorMonitor());
PR_AtomicIncrement(&gInstanceCount);
}
nsEditor::~nsEditor()
@ -184,6 +185,8 @@ nsEditor::~nsEditor()
InsertTextTxn::ClassShutdown();
IMETextTxn::ClassShutdown();
IMECommitTxn::ClassShutdown();
PR_AtomicDecrement(&gInstanceCount);
}

Просмотреть файл

@ -21,7 +21,6 @@
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
#include "prmon.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
@ -66,9 +65,6 @@ class AddStyleSheetTxn;
class RemoveStyleSheetTxn;
class nsFileSpec;
//This is the monitor for the editor.
PRMonitor *GetEditorMonitor();
/** implementation of an editor object. it will be the controler/focal point
* for the main editor services. i.e. the GUIManager, publishing, transaction

Просмотреть файл

@ -304,6 +304,8 @@ nsEditorModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
if (!okToUnload) {
return NS_ERROR_INVALID_POINTER;
}
// we might want to check nsEditor::gInstanceCount == 0 and count
// factory locks here one day.
*okToUnload = PR_FALSE;
return NS_ERROR_FAILURE;
}
@ -336,20 +338,3 @@ extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
gModule = m; // WARNING: Weak Reference
return rv;
}
//!!!!!! This is obsolete is needs to be removed. It should be removed after the calls to
//!!!!!! it are removed.
//if more than one person asks for the monitor at the same time for the FIRST time, we are screwed
PRMonitor *GetEditorMonitor()
{
static PRMonitor *ns_editlock = nsnull;
if (nsnull == ns_editlock)
{
ns_editlock = (PRMonitor *)1; //how long will the next line take? lets cut down on the chance of reentrancy
ns_editlock = PR_NewMonitor();
}
else if ((PRMonitor *)1 == ns_editlock)
return GetEditorMonitor();
return ns_editlock;
}