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

Quelle  TargetShutdownTaskSet.h

  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/. */


#ifndef XPCOM_THREADS_TARGETSHUTDOWNTASKSET_H_
#define XPCOM_THREADS_TARGETSHUTDOWNTASKSET_H_

#include "mozilla/LinkedList.h"
#include "nsITargetShutdownTask.h"

class nsIRunnable;

// TargetShutdownTaskSet manages a set of nsITargetShutdownTask.
// It keeps a strong reference on added tasks until they are either Remove(d)
// or Extract(ed).

class TargetShutdownTaskSet {
 public:
  using TasksList = mozilla::LinkedList<RefPtr<nsITargetShutdownTask>>;
  using TasksArray = AutoTArray<nsCOMPtr<nsITargetShutdownTask>, 8>;

  TargetShutdownTaskSet() = default;
  TargetShutdownTaskSet(TargetShutdownTaskSet&& aOther) = default;
  TargetShutdownTaskSet(TargetShutdownTaskSet& aOther) = delete;

  // Add a task to the set and keep it owned. The caller can forget it if
  // it is not interested in being ever able to remove it.
  // Returns NS_ERROR_UNEXPECTED if the task is already in a
  // TargetShutdownTaskSet.
  nsresult AddTask(nsITargetShutdownTask* aTask) {
    MOZ_ASSERT(aTask);
    MOZ_ASSERT(!mShutdownTasksTaken);
    if (aTask->isInList()) {
      MOZ_ASSERT_UNREACHABLE(
          "A shutdown task can only be registered to one target.");
      return NS_ERROR_UNEXPECTED;
    }
    mShutdownTasks.insertBack(aTask);
    ++mShutdownTaskCount;
    return NS_OK;
  }

  // Remove a task from the set, based on its pointer value.
  // Returns NS_ERROR_UNEXPECTED if the task is not found.
  // Note that RemoveTask releases the set's owning reference on aTask in case
  // it was found.
  nsresult RemoveTask(nsITargetShutdownTask* aTask) {
    MOZ_ASSERT(aTask);
    if (!aTask->isInList()) {
      return NS_ERROR_UNEXPECTED;
    }
    aTask->removeFrom(mShutdownTasks);
    --mShutdownTaskCount;
    return NS_OK;
  }

  // Returns an array with owning pointers of all tasks. This must be called
  // only once. It's the caller's duty to decide how to run them.
  inline TasksArray Extract() {
    MOZ_ASSERT(!mShutdownTasksTaken);
    TasksArray ret;
    ret.SetCapacity(mShutdownTaskCount);
    while (!mShutdownTasks.isEmpty()) {
      auto task = mShutdownTasks.popFirst();
      ret.AppendElement(std::move(task));
    }
    mShutdownTaskCount = 0;
#ifdef DEBUG
    mShutdownTasksTaken = true;
#endif
    return ret;
  }

  bool IsEmpty() { return mShutdownTasks.isEmpty(); }

  ~TargetShutdownTaskSet() { MOZ_ASSERT(mShutdownTasks.isEmpty()); }

 private:
  TasksList mShutdownTasks;
  uint32_t mShutdownTaskCount{0};
#ifdef DEBUG
  bool mShutdownTasksTaken{false};
#endif
};

#endif

Messung V0.5 in Prozent
C=93 H=95 G=93

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© 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.