2021-06-21 00:49:59 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
|
|
// Copyright (c) 2009-2018 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
|
|
|
|
|
2023-07-24 20:42:13 +02:00
|
|
|
#include <util/translation.h> // For bilingual_str
|
|
|
|
|
|
|
|
/** Abort with a message */
|
|
|
|
bool AbortNode(const std::string& strMessage, bilingual_str user_message = bilingual_str{});
|
|
|
|
|
2023-07-16 16:22:36 +02:00
|
|
|
/** Initialize shutdown state. This must be called before using either StartShutdown(),
|
|
|
|
* AbortShutdown() or WaitForShutdown(). Calling ShutdownRequested() is always safe.
|
|
|
|
*/
|
|
|
|
bool InitShutdownState();
|
|
|
|
|
|
|
|
/** Request shutdown of the application. */
|
2021-06-21 00:49:59 +02:00
|
|
|
void StartShutdown();
|
2023-07-16 16:22:36 +02:00
|
|
|
|
|
|
|
/** Request restart of the application. */
|
2021-06-21 00:49:59 +02:00
|
|
|
void StartRestart();
|
2023-07-16 16:22:36 +02:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*/
|
2021-06-21 00:49:59 +02:00
|
|
|
void AbortShutdown();
|
2023-07-16 16:22:36 +02:00
|
|
|
|
|
|
|
/** Returns true if a shutdown is requested, false otherwise. */
|
2021-06-21 00:49:59 +02:00
|
|
|
bool ShutdownRequested();
|
|
|
|
bool RestartRequested();
|
|
|
|
|
2023-07-16 16:22:36 +02:00
|
|
|
/** Wait for StartShutdown to be called in any thread. This can only be used
|
|
|
|
* from a single thread.
|
|
|
|
*/
|
|
|
|
void WaitForShutdown();
|
|
|
|
|
2021-06-21 00:49:59 +02:00
|
|
|
#endif
|