15 #include "google/cloud/terminate_handler.h" 24 class TerminateFunction {
26 TerminateFunction(TerminateHandler f) : f_(std::move(f)) {}
28 TerminateHandler Get() {
29 std::lock_guard<std::mutex> l(m_);
33 TerminateHandler Set(TerminateHandler f) {
34 std::lock_guard<std::mutex> l(m_);
44 TerminateFunction& GetTerminateHolder() {
45 static TerminateFunction f([](
const char* msg) {
46 std::cerr <<
"Aborting because exceptions are disabled: " << msg
56 return GetTerminateHolder().Set(std::move(f));
62 GetTerminateHolder().Get()(msg);
63 std::cerr <<
"Aborting because the installed terminate handler returned. " #define GOOGLE_CLOUD_CPP_NS
Contains all the Google Cloud C++ Library APIs.
TerminateHandler SetTerminateHandler(TerminateHandler f)
Install terminate handler and get the old one atomically.
void Terminate(const char *msg)
Invoke the currently installed handler.
TerminateHandler GetTerminateHandler()
Get the currently installed handler.