Add CleanupRun function to dedup clean list code. Also rename "cleanup" variables to distinguish between cleanup iterators and cleanup callback functions.
These changes were originally part of https://github.com/chaincodelabs/libmultiprocess/pull/126 which was closed for other reasons, but I think they are still helpful and make code easier to navigate.
Since this renames a public struct member, it will require a change to bitcoin core when the depends version is bumped:
diff --git a/src/ipc/capnp/protocol.cpp b/src/ipc/capnp/protocol.cpp
index 4b67a5bd1e36..691bdf5f9242 100644
--- a/src/ipc/capnp/protocol.cpp
+++ b/src/ipc/capnp/protocol.cpp
@@ -73,7 +73,7 @@ public:
}
void addCleanup(std::type_index type, void* iface, std::function<void()> cleanup) override
{
- mp::ProxyTypeRegister::types().at(type)(iface).cleanup.emplace_back(std::move(cleanup));
+ mp::ProxyTypeRegister::types().at(type)(iface).cleanup_fns.emplace_back(std::move(cleanup));
}
Context& context() override { return m_context; }
void startLoop(const char* exe_name)