2 *******************************************************************************
4 * Copyright (C) 2008-2010, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * tab size: 8 (not used)
14 #include "unicode/utypes.h"
19 void *SimpleSingleton::getInstance(InstantiatorFn *instantiator, const void *context,
21 UErrorCode &errorCode) {
23 if(U_FAILURE(errorCode)) {
27 UMTX_CHECK(NULL, fInstance, instance);
31 instance=instantiator(context, errorCode);
33 if(fInstance==NULL && U_SUCCESS(errorCode)) {
42 void *TriStateSingleton::getInstance(InstantiatorFn *instantiator, const void *context,
44 UErrorCode &errorCode) {
46 if(U_FAILURE(errorCode)) {
50 UMTX_CHECK(NULL, fHaveInstance, haveInstance);
52 return fInstance; // instance was created
53 } else if(haveInstance<0) {
54 errorCode=fErrorCode; // instance creation failed
56 } else /* haveInstance==0 */ {
57 void *instance=instantiator(context, errorCode);
59 if(fHaveInstance==0) {
60 if(U_SUCCESS(errorCode)) {
76 void TriStateSingleton::reset() {
78 fErrorCode=U_ZERO_ERROR;
82 #if UCONFIG_NO_SERVICE
84 /* If UCONFIG_NO_SERVICE, then there is no invocation of Mutex elsewhere in
85 common, so add one here to force an export */
86 static Mutex *aMutex = 0;
88 /* UCONFIG_NO_SERVICE */