diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-03-21 14:22:52 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-03-21 14:22:52 (GMT) |
commit | a4933e22d0b56bf07cf35cb90eb1f6fd6c9e48cb (patch) | |
tree | 78f3a200ccbd78c4776b48659f02ed1690a253dd /win | |
parent | 349c1fd2676793625cc0037a11d5989b0a591397 (diff) | |
download | tcl-a4933e22d0b56bf07cf35cb90eb1f6fd6c9e48cb.zip tcl-a4933e22d0b56bf07cf35cb90eb1f6fd6c9e48cb.tar.gz tcl-a4933e22d0b56bf07cf35cb90eb1f6fd6c9e48cb.tar.bz2 |
(experiment) Use TclpMasterLock() in stead of a separate notifierInitMutex. One less mutex to be worried about.
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinNotify.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c index 4543b02..985a769 100644 --- a/win/tclWinNotify.c +++ b/win/tclWinNotify.c @@ -51,7 +51,8 @@ static Tcl_ThreadDataKey dataKey; static int notifierCount = 0; static const TCHAR classname[] = TEXT("TclNotifier"); -TCL_DECLARE_MUTEX(notifierMutex) +static int initialized = 0; +static CRITICAL_SECTION notifierMutex; /* * Static routines defined in this file. @@ -85,12 +86,19 @@ Tcl_InitNotifier(void) ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); WNDCLASS class; + TclpMasterLock(); + if (!initialized) { + initialized = 1; + InitializeCriticalSection(¬ifierMutex); + } + TclpMasterUnlock(); + /* * Register Notifier window class if this is the first thread to use * this module. */ - Tcl_MutexLock(¬ifierMutex); + EnterCriticalSection(¬ifierMutex); if (notifierCount == 0) { class.style = 0; class.cbClsExtra = 0; @@ -108,7 +116,7 @@ Tcl_InitNotifier(void) } } notifierCount++; - Tcl_MutexUnlock(¬ifierMutex); + LeaveCriticalSection(¬ifierMutex); tsdPtr->pending = 0; tsdPtr->timerActive = 0; @@ -183,12 +191,14 @@ Tcl_FinalizeNotifier( * notifier window class. */ - Tcl_MutexLock(¬ifierMutex); - notifierCount--; - if (notifierCount == 0) { - UnregisterClass(classname, TclWinGetTclInstance()); + EnterCriticalSection(¬ifierMutex); + if (notifierCount) { + notifierCount--; + if (notifierCount == 0) { + UnregisterClass(classname, TclWinGetTclInstance()); + } } - Tcl_MutexUnlock(¬ifierMutex); + LeaveCriticalSection(¬ifierMutex); } } |