bitcoin/src/shutdown.cpp
TheCharlatan 6eb33bd0c2
kernel: Add fatalError method to notifications
FatalError replaces what previously was the AbortNode function in
shutdown.cpp.

This commit is part of the libbitcoinkernel project and further removes
the shutdown's and, more generally, the kernel library's dependency on
interface_ui with a kernel notification method. By removing interface_ui
from the kernel library, its dependency on boost is reduced to just
boost::multi_index. At the same time it also takes a step towards
de-globalising the interrupt infrastructure.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2023-06-28 09:52:33 +02:00

44 lines
990 B
C++

// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <shutdown.h>
#include <kernel/context.h>
#include <logging.h>
#include <util/check.h>
#include <util/signalinterrupt.h>
#include <assert.h>
#include <system_error>
void StartShutdown()
{
try {
Assert(kernel::g_context)->interrupt();
} catch (const std::system_error&) {
LogPrintf("Sending shutdown token failed\n");
assert(0);
}
}
void AbortShutdown()
{
Assert(kernel::g_context)->interrupt.reset();
}
bool ShutdownRequested()
{
return bool{Assert(kernel::g_context)->interrupt};
}
void WaitForShutdown()
{
try {
Assert(kernel::g_context)->interrupt.wait();
} catch (const std::system_error&) {
LogPrintf("Reading shutdown token failed\n");
assert(0);
}
}