Create an ExitHandle interface
This is a safer alternative to our existing pattern of capturing the
pointer in a lambda, and it's more Rust-friendly.
Change-Id: Id0f3fe5a2badcf1a4ae871d0cc7c3ff48d1c22f8
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
diff --git a/aos/events/simulated_event_loop.h b/aos/events/simulated_event_loop.h
index 9200044..7b6eaa7 100644
--- a/aos/events/simulated_event_loop.h
+++ b/aos/events/simulated_event_loop.h
@@ -27,6 +27,7 @@
class NodeEventLoopFactory;
class SimulatedEventLoop;
+class SimulatedFactoryExitHandle;
namespace message_bridge {
class SimulatedMessageBridge;
}
@@ -94,6 +95,8 @@
// loop handler.
void Exit();
+ std::unique_ptr<ExitHandle> MakeExitHandle();
+
const std::vector<const Node *> &nodes() const { return nodes_; }
// Sets the simulated send delay for all messages sent within a single node.
@@ -135,6 +138,7 @@
private:
friend class NodeEventLoopFactory;
+ friend class SimulatedFactoryExitHandle;
const Configuration *const configuration_;
EventSchedulerScheduler scheduler_scheduler_;
@@ -147,6 +151,8 @@
std::vector<std::unique_ptr<NodeEventLoopFactory>> node_factories_;
std::vector<const Node *> nodes_;
+
+ int exit_handle_count_ = 0;
};
// This class holds all the state required to be a single node.