Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/ipc/chromium/src/chrome/common/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  ipc_channel_capability.h   Sprache: C

 
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */


#ifndef CHROME_COMMON_IPC_CHANNEL_CAPABILITY_H_
#define CHROME_COMMON_IPC_CHANNEL_CAPABILITY_H_

#include "mozilla/ThreadSafety.h"
#include "mozilla/Mutex.h"
#include "mozilla/EventTargetCapability.h"
#include "nsISerialEventTarget.h"

namespace IPC {

// A thread-safety capability used in IPC channel implementations. Combines an
// EventTargetCapability and a Mutex to allow using each independently, as well
// as combined together.
//
// The ChannelCapability grants shared access if on the IOThread or if the send
// mutex is held, and only allows exclusive access if both on the IO thread and
// holding the send mutex. This is similar to a `MutexSingleWriter`, but more
// flexible due to providing access to each sub-capability.
class MOZ_CAPABILITY("channel cap") ChannelCapability {
 public:
  using Mutex = mozilla::Mutex;
  using Thread = mozilla::EventTargetCapability<nsISerialEventTarget>;

  ChannelCapability(const char* mutex_name, nsISerialEventTarget* io_thread)
      : send_mutex_(mutex_name), io_thread_(io_thread) {}

  const Thread& IOThread() const MOZ_RETURN_CAPABILITY(io_thread_) {
    return io_thread_;
  }
  Mutex& SendMutex() MOZ_RETURN_CAPABILITY(send_mutex_) { return send_mutex_; }

  // Note that we're on the IO thread, and thus have shared access to values
  // guarded by the channel capability for the thread-safety analysis.
  void NoteOnIOThread() const MOZ_REQUIRES(io_thread_)
      MOZ_ASSERT_SHARED_CAPABILITY(this) {}

  // Note that we're holding the send mutex, and thus have shared access to
  // values guarded by the channel capability for the thread-safety analysis.
  void NoteSendMutex() const MOZ_REQUIRES(send_mutex_)
      MOZ_ASSERT_SHARED_CAPABILITY(this) {}

  // Note that we're holding the send mutex while on the IO thread, and thus
  // have exclusive access to values guarded by the channel capability for the
  // thread-safety analysis.
  void NoteExclusiveAccess() const MOZ_REQUIRES(io_thread_, send_mutex_)
      MOZ_ASSERT_CAPABILITY(this) {}

 private:
  mozilla::Mutex send_mutex_;
  mozilla::EventTargetCapability<nsISerialEventTarget> io_thread_;
};

}  // namespace IPC

#endif  // CHROME_COMMON_IPC_CHANNEL_CAPABILITY_H_

Messung V0.5
C=97 H=96 G=96

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.