Index: nspr/pr/include/private/primpl.h |
=================================================================== |
--- nspr/pr/include/private/primpl.h (revision 257452) |
+++ nspr/pr/include/private/primpl.h (working copy) |
@@ -539,6 +539,8 @@ |
_PR_MD_UNLOCK(&(_lock)->ilock); |
extern void _PR_UnblockLockWaiter(PRLock *lock); |
+extern PRStatus _PR_InitLock(PRLock *lock); |
+extern void _PR_FreeLock(PRLock *lock); |
#define _PR_LOCK_PTR(_qp) \ |
((PRLock*) ((char*) (_qp) - offsetof(PRLock,links))) |
@@ -550,8 +552,11 @@ |
#define _PR_CVAR_UNLOCK(_cvar) \ |
_PR_MD_UNLOCK(&(_cvar)->ilock); |
+extern PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock); |
+extern void _PR_FreeCondVar(PRCondVar *cvar); |
extern PRStatus _PR_WaitCondVar( |
PRThread *thread, PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout); |
+extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me); |
extern PRUint32 _PR_CondVarToString(PRCondVar *cvar, char *buf, PRUint32 buflen); |
NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky); |
@@ -1420,8 +1425,6 @@ |
#endif |
}; |
-extern void _PR_InitLocks(void); |
- |
struct PRCondVar { |
PRLock *lock; /* associated lock that protects the condition */ |
#if defined(_PR_PTHREADS) |
@@ -1446,13 +1449,38 @@ |
struct PRMonitor { |
const char* name; /* monitor name for debugging */ |
#if defined(_PR_PTHREADS) |
- PRLock lock; /* the lock structure */ |
- pthread_t owner; /* the owner of the lock or invalid */ |
- PRCondVar *cvar; /* condition variable queue */ |
+ pthread_mutex_t lock; /* lock is only held when accessing fields |
+ * of the PRMonitor, instead of being held |
+ * while the monitor is entered. The only |
+ * exception is notifyTimes, which is |
+ * protected by the monitor. */ |
+ pthread_t owner; /* the owner of the monitor or invalid */ |
+ pthread_cond_t entryCV; /* for threads waiting to enter the monitor */ |
+ |
+ pthread_cond_t waitCV; /* for threads waiting on the monitor */ |
+ PRInt32 refCount; /* reference count, an atomic variable. |
+ * PR_NewMonitor adds a reference to the |
+ * newly created PRMonitor, and |
+ * PR_DestroyMonitor releases that reference. |
+ * PR_ExitMonitor adds a reference before |
+ * unlocking the internal lock if it needs to |
+ * signal entryCV, and releases the reference |
+ * after signaling entryCV. */ |
#else /* defined(_PR_PTHREADS) */ |
- PRCondVar *cvar; /* associated lock and condition variable queue */ |
+ PRLock lock; /* lock is only held when accessing fields |
+ * of the PRMonitor, instead of being held |
+ * while the monitor is entered. The only |
+ * exception is notifyTimes, which is |
+ * protected by the monitor. */ |
+ PRThread *owner; /* the owner of the monitor or invalid */ |
+ PRCondVar entryCV; /* for threads waiting to enter the monitor */ |
+ |
+ PRCondVar waitCV; /* for threads waiting on the monitor */ |
#endif /* defined(_PR_PTHREADS) */ |
PRUint32 entryCount; /* # of times re-entered */ |
+ PRIntn notifyTimes; /* number of pending notifies for waitCV. |
+ * The special value -1 means a broadcast |
+ * (PR_NotifyAll). */ |
}; |
/************************************************************************/ |
@@ -1472,8 +1500,6 @@ |
#endif /* defined(_PR_BTHREADS) */ |
}; |
-NSPR_API(void) _PR_InitSem(void); |
- |
/*************************************************************************/ |
struct PRSem { |
@@ -1555,6 +1581,8 @@ |
#if defined(_PR_PTHREADS) |
pthread_t id; /* pthread identifier for the thread */ |
+ PRBool idSet; /* whether 'id' has been set. Protected by |
+ * pt_book.ml. */ |
#ifdef _PR_NICE_PRIORITY_SCHEDULING |
pid_t tid; /* Linux-specific kernel thread ID */ |
#endif |
@@ -1745,6 +1773,7 @@ |
}; |
#endif /* MOZ_UNICODE */ |
+extern void _PR_InitLocks(void); |
extern void _PR_InitSegs(void); |
extern void _PR_InitStacks(void); |
extern void _PR_InitTPD(void); |
@@ -1762,7 +1791,6 @@ |
extern void _PR_InitTime(void); |
extern void _PR_InitMW(void); |
extern void _PR_InitRWLocks(void); |
-extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me); |
extern void _PR_CleanupThread(PRThread *thread); |
extern void _PR_CleanupCallOnce(void); |
extern void _PR_CleanupMW(void); |