aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/context.h
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-06-01 16:53:33 -0400
committerTheCharlatan <seb.kung@gmail.com>2023-06-28 09:49:28 +0200
commite2d680a32d757de0ef8eb836047a0daa1d82e3c4 (patch)
tree5115b92fc4fe97697c27ad43617984551ae5646c /src/kernel/context.h
parentd9c7c2fd3ec7b0fcae7e0c9423bff6c6799dd67c (diff)
util: Add SignalInterrupt class and use in shutdown.cpp
This change helps generalize shutdown code so an interrupt can be provided to libbitcoinkernel callers. This may also be useful to eventually de-globalize all of the shutdown code. Co-authored-by: Russell Yanofsky <russ@yanofsky.org> Co-authored-by: TheCharlatan <seb.kung@gmail.com>
Diffstat (limited to 'src/kernel/context.h')
-rw-r--r--src/kernel/context.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/kernel/context.h b/src/kernel/context.h
index f11b7b54f0..e74e0a6f08 100644
--- a/src/kernel/context.h
+++ b/src/kernel/context.h
@@ -5,6 +5,8 @@
#ifndef BITCOIN_KERNEL_CONTEXT_H
#define BITCOIN_KERNEL_CONTEXT_H
+#include <util/signalinterrupt.h>
+
#include <memory>
namespace kernel {
@@ -16,12 +18,24 @@ namespace kernel {
//! State stored directly in this struct should be simple. More complex state
//! should be stored to std::unique_ptr members pointing to opaque types.
struct Context {
+ //! Interrupt object that can be used to stop long-running kernel operations.
+ util::SignalInterrupt interrupt;
+
//! Declare default constructor and destructor that are not inline, so code
//! instantiating the kernel::Context struct doesn't need to #include class
//! definitions for all the unique_ptr members.
Context();
~Context();
};
+
+//! Global pointer to kernel::Context for legacy code. New code should avoid
+//! using this, and require state it needs to be passed to it directly.
+//!
+//! Having this pointer is useful because it allows state be moved out of global
+//! variables into the kernel::Context struct before all global references to
+//! that state are removed. This allows the global references to be removed
+//! incrementally, instead of all at once.
+extern Context* g_context;
} // namespace kernel
#endif // BITCOIN_KERNEL_CONTEXT_H