]> AND Public Git Repository - simgrid.git/blobdiff - src/mc/remote/CheckerSide.hpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add first batch of tests for History class
[simgrid.git] / src / mc / remote / CheckerSide.hpp
index ff844b5a2468fe1af1ceada92ec3f4bf160f17d5..287bf896dfc44ba73f1c8fbec4f062fe0bbc4362 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <event2/event.h>
 #include <functional>
+#include <memory>
 
-namespace simgrid {
-namespace mc {
+namespace simgrid::mc {
 
 class CheckerSide {
-  struct event_base* base_    = nullptr;
-  struct event* socket_event_ = nullptr;
-  struct event* signal_event_ = nullptr;
+  std::unique_ptr<event_base, decltype(&event_base_free)> base_{nullptr, &event_base_free};
+  std::unique_ptr<event, decltype(&event_free)> socket_event_{nullptr, &event_free};
+  std::unique_ptr<event, decltype(&event_free)> signal_event_{nullptr, &event_free};
 
   Channel channel_;
 
 public:
   explicit CheckerSide(int sockfd) : channel_(sockfd) {}
-  ~CheckerSide();
 
   // No copy:
   CheckerSide(CheckerSide const&) = delete;
@@ -35,11 +34,10 @@ public:
   Channel& get_channel() { return channel_; }
 
   void start(void (*handler)(int, short, void*), ModelChecker* mc);
-  void dispatch();
-  void break_loop();
+  void dispatch() const;
+  void break_loop() const;
 };
 
-} // namespace mc
-} // namespace simgrid
+} // namespace simgrid::mc
 
 #endif