Bitcoin Core  21.99.0
P2P Digital Currency
Functions | Variables
shutdown.cpp File Reference
#include <shutdown.h>
#include <config/bitcoin-config.h>
#include <assert.h>
#include <atomic>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
Include dependency graph for shutdown.cpp:

Go to the source code of this file.

Functions

static std::atomic< bool > fRequestShutdown (false)
 
bool InitShutdownState ()
 Initialize shutdown state. More...
 
void StartShutdown ()
 Request shutdown of the application. More...
 
void AbortShutdown ()
 Clear shutdown flag. More...
 
bool ShutdownRequested ()
 Returns true if a shutdown is requested, false otherwise. More...
 
void WaitForShutdown ()
 Wait for StartShutdown to be called in any thread. More...
 

Variables

static int g_shutdown_pipe [2] = {-1, -1}
 On UNIX-like operating systems use the self-pipe trick. More...
 

Function Documentation

◆ AbortShutdown()

void AbortShutdown ( )

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.

Definition at line 78 of file shutdown.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fRequestShutdown()

static std::atomic<bool> fRequestShutdown ( false  )
static
Here is the caller graph for this function:

◆ InitShutdownState()

bool InitShutdownState ( )

Initialize shutdown state.

This must be called before using either StartShutdown(), AbortShutdown() or WaitForShutdown(). Calling ShutdownRequested() is always safe.

Definition at line 32 of file shutdown.cpp.

Here is the caller graph for this function:

◆ ShutdownRequested()

bool ShutdownRequested ( )

Returns true if a shutdown is requested, false otherwise.

Definition at line 88 of file shutdown.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartShutdown()

void StartShutdown ( )

Request shutdown of the application.

Definition at line 50 of file shutdown.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WaitForShutdown()

void WaitForShutdown ( )

Wait for StartShutdown to be called in any thread.

This can only be used from a single thread.

Definition at line 93 of file shutdown.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_shutdown_pipe

int g_shutdown_pipe[2] = {-1, -1}
static

On UNIX-like operating systems use the self-pipe trick.

Index 0 will be the read end of the pipe, index 1 the write end.

Definition at line 29 of file shutdown.cpp.