ICU-3156 fix problems with ICU_USE_THREADS and the revised mutexes.

X-SVN-Rev: 12803
This commit is contained in:
Andy Heninger 2003-08-10 23:57:35 +00:00
parent bee5e57ebb
commit 58fc849c4f
4 changed files with 7 additions and 17 deletions

View File

@ -137,8 +137,6 @@ U_CFUNC UBool u_ICUStaticInitFunc()
{
UErrorCode status = U_ZERO_ERROR;
#if (ICU_USE_THREADS == 1)
/* Initialize mutexes only if threading is supported */
UBool heapInUse = cmemory_inUse();
umtx_init(NULL);
ucnv_init(&status);
@ -149,7 +147,6 @@ U_CFUNC UBool u_ICUStaticInitFunc()
* have done some heap allocation. */
cmemory_clearInUse();
}
#endif /* ICU_USE_THREADS==1 */
return TRUE;
}

View File

@ -277,14 +277,13 @@ umtx_destroy(UMTX *mutex) {
#if (ICU_USE_THREADS == 1)
#if defined (WIN32)
DeleteCriticalSection((CRITICAL_SECTION*)*mutex);
uprv_free(*mutex);
#elif defined (POSIX)
pthread_mutex_destroy((pthread_mutex_t*)*mutex);
uprv_free(*mutex);
#endif
#endif /* ICU_USE_THREADS==1 */
uprv_free(*mutex);
}
*mutex = NULL;

View File

@ -136,7 +136,7 @@ typedef void U_CALLCONV UMtxFunc (const void *context, UMTX *mutex);
* This function can only be used when ICU is in an initial, unused state, before
* u_init() has been called.
* This function may be used even when ICU has been built without multi-threaded
* support (see ICU_USE_THREADS pre-processor variable)
* support (see ICU_USE_THREADS pre-processor variable, umutex.h)
* @param context This pointer value will be saved, and then (later) passed as
* a parameter to the increment and decrement functions each time they
* are called. This function can only be called

View File

@ -11,6 +11,9 @@
#endif
#include <unicode/umachine.h>
#include "unicode/utypes.h"
#include "umutex.h"
// Just turn off threads on cygwin, so that we can test
// the other stuff. This needs to be investigated further.
@ -66,17 +69,7 @@
#undef sleep
#endif
#include "unicode/utypes.h"
/* APP_NO_THREADS is an old symbol. We'll honour it if present. */
#ifdef APP_NO_THREADS
# define ICU_USE_THREADS 0
#endif
/* Default: use threads. */
#ifndef ICU_USE_THREADS
# define ICU_USE_THREADS 1
#endif
#include "tsmthred.h"
@ -894,6 +887,7 @@ void MultithreadTest::TestThreadedIntl()
}
umtx_destroy(&ftMutex);
return;
}
#endif /* #if !UCONFIG_NO_FORMATTING */