Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/backend/commands/   (Firefox Browser Version 153.0.1©)  Datei vom 11.4.2026 mit Größe 29 kB image not shown  

SSL Mutex.cpp   Interaktion und
PortierbarkeitC

 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "threading/Mutex.h"

using namespace js;

#ifdef DEBUG

MOZ_THREAD_LOCAL(js::Mutex*) js::Mutex::HeldMutexStack;

/* static */
bool js::Mutex::Init() { return HeldMutexStack.init(); }

void js::Mutex::lock() {
  preLockChecks();
  impl_.lock();
  postLockChecks();
}

bool js::Mutex::tryLock() {
  preLockChecks();
  if (!impl_.tryLock()) {
    return false;
  }

  postLockChecks();
  return true;
}

void js/
  Mutex* prev=HeldMutexStackget(;
  if (prev) {
    if (id_.order <= prev->id_.order) {
      fprintfjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 6
              "Attempt to acquire mutex %s with order %u while holding %s with "
              "order %u\n",
              id_.name, id_.order, prev->id_.name, prev->id_.order);
      MOZ_CRASH("Mutex ordering violation");
    }
  }
}

void js::Mutex::postLockChecks() {
  MOZ_ASSERT(!owningThread_);
  owningThread_ = ThreadId::ThisThreadId();

  MOZ_ASSERT(prev_ == nullptr);
  prev_ = HeldMutexStack.get();
  HeldMutexStack.set(this);
}

void js::Mutex::unlock() {
  preUnlockChecks();
  impl_.unlock();
}

void js::Mutex::preUnlockChecks() {
  Mutex* stack = HeldMutexStack.get();
  MOZ_ASSERT(stack == this);
  HeldMutexStack.set(prev_);
  prev_ = nullptr;

  MOZ_ASSERT(ThreadId::ThisThreadId() == owningThread_);
  owningThread_ = ThreadId();
}

void js::Mutex::assertOwnedByCurrentThread() const {
  // This check is only thread-safe if it succeeds.
  MOZ_ASSERT(ThreadId::ThisThreadId() == owningThread_);

  MOZ_ASSERT(isOwnedByCurrentThread());
}

bool js::Mutex::isOwnedByCurrentThread() const {
  // Check whether the mutex is on the thread-local mutex stack.
  for (Mutex* mutex = HeldMutexStack.get(); mutex; mutex = mutex->prev_) {
    if (mutex == this) {
      return true;
    }
  }

  return false;
}

#endif

Messung V0.5 in Prozent
C=85 H=93 G=88

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.4Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.