예제 #1
0
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;
}
예제 #2
0
static void
PollGtkExit(void)
{
   Poll *poll = pollState;

   ASSERT(poll != NULL);

   PollGtkLock();
   g_hash_table_destroy(poll->deviceTable);
   g_hash_table_destroy(poll->timerTable);
   poll->deviceTable = NULL;
   poll->timerTable = NULL;
#ifdef _WIN32
   g_hash_table_destroy(poll->signaledTable);
   poll->signaledTable = NULL;
   g_slist_free(poll->newSignaled);
   poll->newSignaled = NULL;
   if (poll->retrySource > 0) {
      g_source_remove(poll->retrySource);
      poll->retrySource = 0;
   }
#endif
   PollGtkUnlock();

   MXUser_DestroyExclLock(poll->lock);

   g_free(poll);
   pollState = NULL;
}