TITLE: multiple creations of CMPI_ThreadContext::contextKey
DESCRIPTION: Serialized creation of CMPI_ThreadContext::contextKey using Once class.
PEGASUS_NAMESPACE_BEGIN
TSDKeyType CMPI_ThreadContext::contextKey;
-int CMPI_ThreadContext::context_key_once=1;
+Once CMPI_ThreadContext::contextKeyOnce = PEGASUS_ONCE_INITIALIZER;
void CMPI_ThreadContext::context_key_alloc()
{
TSDKeyType CMPI_ThreadContext::getContextKey()
{
- if( context_key_once )
- {
- context_key_alloc();
- context_key_once=0;
- }
+ once(&contextKeyOnce, context_key_alloc);
return contextKey;
}
#endif
#include <Pegasus/Common/TSDKey.h>
+#include <Pegasus/Common/Once.h>
#include <Pegasus/Provider/CMPI/cmpidt.h>
#include <Pegasus/Provider/CMPI/cmpift.h>
static pthread_key_t contextKey;
*/
static TSDKeyType contextKey;
- static int context_key_once;
+ static Once contextKeyOnce;
static void context_key_alloc();
/**
static pthread_key_t getContextKey();