MXUserExclLock * MXUser_CreateSingletonExclLock(Atomic_Ptr *lockStorage, // IN/OUT: const char *name, // IN: MX_Rank rank) // IN: { MXUserExclLock *lock; ASSERT(lockStorage); lock = Atomic_ReadPtr(lockStorage); if (UNLIKELY(lock == NULL)) { MXUserExclLock *newLock = MXUser_CreateExclLock(name, rank); lock = Atomic_ReadIfEqualWritePtr(lockStorage, NULL, (void *) newLock); if (lock) { MXUser_DestroyExclLock(newLock); } else { lock = Atomic_ReadPtr(lockStorage); } } return lock; }
static void PollGtkInit(void) { ASSERT(pollState == NULL); pollState = g_new0(Poll, 1); pollState->lock = MXUser_CreateExclLock("pollGtkLock", RANK_pollDefaultLock); pollState->deviceTable = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, PollGtkRemoveOneCallback); ASSERT(pollState->deviceTable); pollState->timerTable = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, PollGtkRemoveOneCallback); ASSERT(pollState->timerTable); #ifdef _WIN32 pollState->signaledTable = g_hash_table_new(g_direct_hash, g_direct_equal); ASSERT(pollState->signaledTable); #endif }