LCOV - code coverage report
Current view: top level - src - shutdown.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 1 20 5.0 %
Date: 2023-09-26 12:08:55 Functions: 1 5 20.0 %

          Line data    Source code
       1             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2022 The Bitcoin Core developers
       3             : // Distributed under the MIT software license, see the accompanying
       4             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5             : 
       6             : #include <shutdown.h>
       7             : 
       8             : #include <kernel/context.h>
       9             : #include <logging.h>
      10             : #include <util/check.h>
      11             : #include <util/signalinterrupt.h>
      12             : 
      13             : #include <assert.h>
      14             : #include <system_error>
      15             : 
      16           0 : void StartShutdown()
      17             : {
      18             :     try {
      19           0 :         Assert(kernel::g_context)->interrupt();
      20           0 :     } catch (const std::system_error&) {
      21           0 :         LogPrintf("Sending shutdown token failed\n");
      22           0 :         assert(0);
      23           0 :     }
      24           0 : }
      25             : 
      26           0 : void AbortShutdown()
      27             : {
      28           0 :     Assert(kernel::g_context)->interrupt.reset();
      29           0 : }
      30             : 
      31           0 : bool ShutdownRequested()
      32             : {
      33           0 :     return bool{Assert(kernel::g_context)->interrupt};
      34             : }
      35             : 
      36           0 : void WaitForShutdown()
      37             : {
      38             :     try {
      39           0 :         Assert(kernel::g_context)->interrupt.wait();
      40           0 :     } catch (const std::system_error&) {
      41           0 :         LogPrintf("Reading shutdown token failed\n");
      42           0 :         assert(0);
      43           0 :     }
      44           0 : }

Generated by: LCOV version 1.14