Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/mozglue/misc/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  ConditionVariable_futex.cpp

  Sprache: C
 

/* 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 "mozilla/PlatformConditionVariable.h"
#include "mozilla/PlatformMutex.h"
#include "mozilla/Futex.h"

// All the memory orderings here are relaxed, because synchronization is done
// by unlocking and locking the mutex.

mozilla::detail::ConditionVariableImpl::ConditionVariableImpl() = default;
mozilla::detail::ConditionVariableImpl::~ConditionVariableImpl() = default;

void mozilla::detail::ConditionVariableImpl::notify_one() {
  mFutex.mValue.fetch_add(1, std::memory_order_relaxed);
  mFutex.wake();
}

void mozilla::detail::ConditionVariableImpl::notify_all() {
  mFutex.mValue.fetch_add(1, std::memory_order_relaxed);
  mFutex.wakeAll();
}

void mozilla::detail::ConditionVariableImpl::wait(MutexImpl& lock) {
  wait_for(lock, TimeDuration::Forever());
}

mozilla::CVStatus mozilla::detail::ConditionVariableImpl::wait_for(
    MutexImpl& lock, const mozilla::TimeDuration& rel_time) {
  // Examine the notification counter _before_ we unlock the mutex.
  uint32_t value = mFutex.mValue.load(std::memory_order_relaxed);
  // Unlock the mutex before going to sleep.
  lock.unlock();
  // Wait, but only if there hasn't been any notification since we unlocked the
  // mutex.
  bool r = mFutex.wait(value, &rel_time);
  // Lock the mutex again.
  lock.lock();
  return r ? CVStatus::NoTimeout : CVStatus::Timeout;
}

Messung V0.5 in Prozent
C=91 H=95 G=92

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






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.