Bitcoin Core  26.99.0
P2P Digital Currency
shutdown.cpp
Go to the documentation of this file.
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 
17 {
18  try {
19  Assert(kernel::g_context)->interrupt();
20  } catch (const std::system_error&) {
21  LogPrintf("Sending shutdown token failed\n");
22  assert(0);
23  }
24 }
25 
27 {
28  Assert(kernel::g_context)->interrupt.reset();
29 }
30 
32 {
33  return bool{Assert(kernel::g_context)->interrupt};
34 }
35 
37 {
38  try {
39  Assert(kernel::g_context)->interrupt.wait();
40  } catch (const std::system_error&) {
41  LogPrintf("Reading shutdown token failed\n");
42  assert(0);
43  }
44 }
#define Assert(val)
Identity function.
Definition: check.h:77
#define LogPrintf(...)
Definition: logging.h:237
Context * g_context
Global pointer to kernel::Context for legacy code.
Definition: context.cpp:17
void WaitForShutdown()
Wait for StartShutdown to be called in any thread.
Definition: shutdown.cpp:36
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
Definition: shutdown.cpp:31
void StartShutdown()
Request shutdown of the application.
Definition: shutdown.cpp:16
void AbortShutdown()
Clear shutdown flag.
Definition: shutdown.cpp:26
assert(!tx.IsCoinBase())