LCOV - code coverage report
Current view: top level - gjs - promise.h (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 100.0 % 1 1
Test Date: 2025-02-09 21:27:27 Functions: - 0 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
       2                 :             : // SPDX-FileCopyrightText: 2021 Evan Welsh <contact@evanwelsh.com>
       3                 :             : 
       4                 :             : #pragma once
       5                 :             : 
       6                 :             : #include <config.h>
       7                 :             : 
       8                 :             : #include <memory>
       9                 :             : 
      10                 :             : #include <glib.h>
      11                 :             : 
      12                 :             : #include <js/TypeDecls.h>
      13                 :             : 
      14                 :             : #include "gjs/auto.h"
      15                 :             : 
      16                 :             : class GjsContextPrivate;
      17                 :             : 
      18                 :             : namespace Gjs {
      19                 :             : 
      20                 :             : using AutoMainContext = AutoPointer<GMainContext, GMainContext,
      21                 :         508 :                                     g_main_context_unref, g_main_context_ref>;
      22                 :             : 
      23                 :             : /**
      24                 :             :  * @brief A class which wraps a custom GSource and handles associating it with a
      25                 :             :  * GMainContext. While it is running, it will attach the source to the main
      26                 :             :  * context so that promise jobs are run at the appropriate time.
      27                 :             :  */
      28                 :             : class PromiseJobDispatcher {
      29                 :             :     class Source;
      30                 :             :     // The thread-default GMainContext
      31                 :             :     AutoMainContext m_main_context;
      32                 :             :     // The custom source.
      33                 :             :     std::unique_ptr<Source> m_source;
      34                 :             : 
      35                 :             :  public:
      36                 :             :     explicit PromiseJobDispatcher(GjsContextPrivate*);
      37                 :             :     ~PromiseJobDispatcher();
      38                 :             : 
      39                 :             :     /**
      40                 :             :      * @brief Start (or resume) dispatching jobs from the promise job queue
      41                 :             :      */
      42                 :             :     void start();
      43                 :             : 
      44                 :             :     /**
      45                 :             :      * @brief Stop dispatching
      46                 :             :      */
      47                 :             :     void stop();
      48                 :             : 
      49                 :             :     /**
      50                 :             :      * @brief Whether the dispatcher is currently running
      51                 :             :      */
      52                 :             :     bool is_running();
      53                 :             : };
      54                 :             : 
      55                 :             : };  // namespace Gjs
      56                 :             : 
      57                 :             : bool gjs_define_native_promise_stuff(JSContext* cx,
      58                 :             :                                      JS::MutableHandleObject module);
        

Generated by: LCOV version 2.0-1