Example #1
0
void
cc_mutex_lock(cc_mutex * mutex)
{
  int ok;
  SbBool timeit;
  cc_time start = 0.0;

  assert(mutex != NULL);

  timeit = (maxmutexlocktime != DBL_MAX) || (reportmutexlocktiming != DBL_MAX);
  if (timeit) { start = cc_time_gettimeofday(); }

#ifdef USE_W32THREAD
  ok = cc_mutex_TryEnterCriticalSection ? win32_cs_lock(mutex) : win32_mutex_lock(mutex);
#else /* USE_W32THREAD */  
  ok = internal_mutex_lock(mutex);
#endif /* USE_W32THREAD */

  assert(ok == CC_OK);

  /* This is here as an optional debugging aid, when having problems
     related to locks that are held too long. (Typically resulting in
     unresponsive user interaction / lags.)  */
  if (timeit) {
    const cc_time spent = cc_time_gettimeofday() - start;

    if (spent >= reportmutexlocktiming) {
      /* Can't use cc_debugerror_postinfo() here, because we get a
         recursive call to this function, and a non-terminating lock /
         hang. */
      (void)fprintf(stdout, "DEBUG cc_mutex_lock(): mutex %p spent %f secs in lock\n",
                    mutex, spent);
    }

    assert(spent <= maxmutexlocktime);
  }
}
Example #2
0
 void
 LockImplement(void)
 {
     internal_mutex_lock();
 }
Example #3
0
/* This method locks the mutex. */
void kmutex_lock(struct kmutex *self) {
    internal_mutex_lock(&self->internal_mutex);
}