Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/devtools/client/debugger/src/reducers/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  threads.js   Sprache: JAVA

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


/**
 * Threads reducer
 * @module reducers/threads
 */


import { sortThreads } from "./sources-tree.js";

const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
  BinarySearch: "resource://gre/modules/BinarySearch.sys.mjs",
});

export function initialThreadsState() {
  return {
    threads: [],

    // List of thread actor IDs which are current tracing.
    // i.e. where JavaScript tracing is enabled.
    mutableTracingThreads: new Set(),
  };
}

export default function update(state = initialThreadsState(), action) {
  switch (action.type) {
    case "INSERT_THREAD": {
      const { newThread } = action;
      if (newThread.isTopLevel) {
        return {
          ...state,
          threads: [newThread, ...state.threads],
        };
      }

      const index = lazy.BinarySearch.insertionIndexOf(
        sortThreads,
        state.threads,
        newThread
      );
      return {
        ...state,
        threads: state.threads.toSpliced(index, 0, newThread),
      };
    }

    case "REMOVE_THREAD":
      return {
        ...state,
        threads: state.threads.filter(
          thread => action.threadActorID != thread.actor
        ),
      };

    case "UPDATE_SERVICE_WORKER_STATUS":
      return {
        ...state,
        threads: state.threads.map(t => {
          if (t.actor == action.thread) {
            return { ...t, serviceWorkerStatus: action.status };
          }
          return t;
        }),
      };

    case "TRACING_TOGGLED":
      const { mutableTracingThreads } = state;
      const sizeBefore = mutableTracingThreads.size;
      if (action.enabled) {
        mutableTracingThreads.add(action.thread);
      } else {
        mutableTracingThreads.delete(action.thread);
      }
      // We may receive toggle events when we change the logging method
      // while we are already tracing, but the list of tracing thread stays the same.
      const changed = mutableTracingThreads.size != sizeBefore;
      if (changed) {
        return {
          ...state,
          mutableTracingThreads,
        };
      }
      return state;

    default:
      return state;
  }
}

Messung V0.5
C=94 H=90 G=91

¤ Dauer der Verarbeitung: 0.4 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.