Exemplo n.º 1
0
void
RWLock::WriteUnlockInternal()
{
#ifdef XP_WIN
  ReleaseSRWLockExclusive(NativeHandle(mRWLock));
#else
  MOZ_RELEASE_ASSERT(pthread_rwlock_unlock(NativeHandle(mRWLock)) == 0,
                     "pthread_rwlock_unlock failed");
#endif
}
Exemplo n.º 2
0
void
RWLock::ReadLockInternal()
{
#ifdef XP_WIN
  AcquireSRWLockShared(NativeHandle(mRWLock));
#else
  MOZ_RELEASE_ASSERT(pthread_rwlock_rdlock(NativeHandle(mRWLock)) == 0,
                     "pthread_rwlock_rdlock failed");
#endif
}
Exemplo n.º 3
0
RWLock::RWLock(const char* aName)
  : BlockingResourceBase(aName, eMutex)
#ifdef DEBUG
  , mOwningThread(nullptr)
#endif
{
#ifdef XP_WIN
  InitializeSRWLock(NativeHandle(mRWLock));
#else
  MOZ_RELEASE_ASSERT(pthread_rwlock_init(NativeHandle(mRWLock), nullptr) == 0,
                     "pthread_rwlock_init failed");
#endif
}
Exemplo n.º 4
0
bool LqThreadBase::SetAffinity(uint64_t Mask) {
    bool Res = true;
    StartThreadLocker.LockWrite();
    if(AffinMask != Mask) {
        AffinMask = Mask;
        if(IsThreadRunning()) {
#if defined(LQPLATFORM_WINDOWS)
            SetThreadAffinityMask((HANDLE)NativeHandle(), Mask);
#elif !defined(LQPLATFORM_ANDROID)
            pthread_setaffinity_np(NativeHandle(), sizeof(Mask), (const cpu_set_t*)&Mask);
#endif
        } else {
            lq_errno_set(ENOENT);
            Res = false;
        }
    }
    StartThreadLocker.UnlockWrite();
    return Res;
}
Exemplo n.º 5
0
bool LqThreadBase::SetPriority(LqThreadPriorEnm New) {
    bool Res = true;
    StartThreadLocker.LockWrite();
    if(Priority != New) {
        Priority = New;
        if(IsThreadRunning()) {
#if defined(LQPLATFORM_WINDOWS)
            SetThreadPriority((HANDLE)NativeHandle(), __GetRealPrior(Priority));
#else
            sched_param schedparams;
            schedparams.sched_priority = __GetRealPrior(Priority);
            pthread_setschedparam(NativeHandle(), SCHED_OTHER, &schedparams);
#endif
        } else {
            lq_errno_set(ENOENT);
            Res = false;
        }
    }
    StartThreadLocker.UnlockWrite();
    return Res;
}
Exemplo n.º 6
0
#endif
{
  MOZ_GUARD_OBJECT_NOTIFIER_INIT;
#ifdef XP_WIN
  // This number was adapted from NSPR.
  static const DWORD sLockSpinCount = 100;

#if defined(RELEASE_OR_BETA)
  // Vista and later automatically allocate and subsequently leak a debug info
  // object for each critical section that we allocate unless we tell the
  // system not to do that.
  DWORD flags = CRITICAL_SECTION_NO_DEBUG_INFO;
#else
  DWORD flags = 0;
#endif
  BOOL r = InitializeCriticalSectionEx(NativeHandle(mMutex),
                                       sLockSpinCount, flags);
  MOZ_RELEASE_ASSERT(r);
#else
  pthread_mutexattr_t attr;

  MOZ_RELEASE_ASSERT(pthread_mutexattr_init(&attr) == 0,
                     "pthread_mutexattr_init failed");

  MOZ_RELEASE_ASSERT(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) == 0,
                     "pthread_mutexattr_settype failed");

  MOZ_RELEASE_ASSERT(pthread_mutex_init(&mMutex, &attr) == 0,
                     "pthread_mutex_init failed");

  MOZ_RELEASE_ASSERT(pthread_mutexattr_destroy(&attr) == 0,
Exemplo n.º 7
0
RWLock::~RWLock()
{
  MOZ_RELEASE_ASSERT(pthread_rwlock_destroy(NativeHandle(mRWLock)) == 0,
                     "pthread_rwlock_destroy failed");
}