mirror of https://github.com/bitcoin/bitcoin
This change is mostly a refectoring that removes some code and gets rid of an unnecessary layer of indirection after #27861 But it is not a pure refactoring since StartShutdown, AbortShutdown, and WaitForShutdown functions used to abort on failure, and the replacement code logs or returns errors instead.pull/28051/head
parent
213542b625
commit
6db04be102
@ -1,43 +0,0 @@
|
||||
// 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()
|
||||
{
|
||||
if (!Assert(kernel::g_context)->interrupt()) {
|
||||
LogPrintf("Sending shutdown token failed\n");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
void AbortShutdown()
|
||||
{
|
||||
if (!Assert(kernel::g_context)->interrupt.reset()) {
|
||||
LogPrintf("Reading shutdown token failed\n");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool ShutdownRequested()
|
||||
{
|
||||
return bool{Assert(kernel::g_context)->interrupt};
|
||||
}
|
||||
|
||||
void WaitForShutdown()
|
||||
{
|
||||
if (!Assert(kernel::g_context)->interrupt.wait()) {
|
||||
LogPrintf("Reading shutdown token failed\n");
|
||||
assert(0);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2021 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_SHUTDOWN_H
|
||||
#define BITCOIN_SHUTDOWN_H
|
||||
|
||||
/** Request shutdown of the application. */
|
||||
void StartShutdown();
|
||||
|
||||
/** Clear shutdown flag. Only use this during init (before calling WaitForShutdown in any
|
||||
* thread), or in the unit tests. Calling it in other circumstances will cause a race condition.
|
||||
*/
|
||||
void AbortShutdown();
|
||||
|
||||
/** Returns true if a shutdown is requested, false otherwise. */
|
||||
bool ShutdownRequested();
|
||||
|
||||
/** Wait for StartShutdown to be called in any thread. This can only be used
|
||||
* from a single thread.
|
||||
*/
|
||||
void WaitForShutdown();
|
||||
|
||||
#endif // BITCOIN_SHUTDOWN_H
|
Loading…
Reference in new issue