tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ConditionVariable_noop.cpp (1405B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/PlatformConditionVariable.h"
      8 #include "mozilla/PlatformMutex.h"
      9 #include "MutexPlatformData_noop.h"
     10 
     11 using mozilla::TimeDuration;
     12 
     13 struct mozilla::detail::ConditionVariableImpl::PlatformData {};
     14 
     15 mozilla::detail::ConditionVariableImpl::ConditionVariableImpl() {}
     16 
     17 mozilla::detail::ConditionVariableImpl::~ConditionVariableImpl() {}
     18 
     19 void mozilla::detail::ConditionVariableImpl::notify_one() {}
     20 
     21 void mozilla::detail::ConditionVariableImpl::notify_all() {}
     22 
     23 void mozilla::detail::ConditionVariableImpl::wait(MutexImpl&) {
     24  // On WASI, there are no threads, so we never wait (either the condvar must
     25  // be ready or there is a deadlock).
     26 }
     27 
     28 mozilla::CVStatus mozilla::detail::ConditionVariableImpl::wait_for(
     29    MutexImpl&, const TimeDuration&) {
     30  return CVStatus::NoTimeout;
     31 }
     32 
     33 mozilla::detail::ConditionVariableImpl::PlatformData*
     34 mozilla::detail::ConditionVariableImpl::platformData() {
     35  static_assert(sizeof platformData_ >= sizeof(PlatformData),
     36                "platformData_ is too small");
     37  return reinterpret_cast<PlatformData*>(platformData_);
     38 }