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