#define S4U_CHORD_HPP
#include "simgrid/s4u.hpp"
#include <string>
-#include <xbt/RngStream.h>
+#include <xbt/random.hpp>
#include <xbt/str.h>
constexpr double MAX_SIMULATION_TIME = 1000;
extern int nb_keys;
extern int timeout;
-class HostChord {
- RngStream stream_;
- simgrid::s4u::Host* host = nullptr;
-
-public:
- static simgrid::xbt::Extension<simgrid::s4u::Host, HostChord> EXTENSION_ID;
-
- explicit HostChord(simgrid::s4u::Host* ptr) : host(ptr)
- {
- std::string descr = std::string("RngSream<") + host->get_cname() + ">";
- stream_ = RngStream_CreateStream(descr.c_str());
- }
- HostChord(const HostChord&) = delete;
- HostChord& operator=(const HostChord&) = delete;
-
- ~HostChord() { RngStream_DeleteStream(&stream_); };
-
- RngStream getStream() { return stream_; };
-};
-
/* Types of tasks exchanged between nodes. */
enum e_message_type_t {
FIND_SUCCESSOR,
{
}
- ~ChordMessage() = default;
-
static void destroy(void* message);
};
int id_; // my id
int pred_id_ = -1; // predecessor id
simgrid::s4u::Mailbox* mailbox_; // my mailbox
- int* fingers_; // finger table,(fingers[0] is my successor)
+ std::vector<int> fingers_; // finger table,(fingers[0] is my successor)
int next_finger_to_fix; // index of the next finger to fix in fix_fingers()
- RngStream stream;
public:
explicit Node(std::vector<std::string> args);
Node(const Node&) = delete;
Node& operator=(const Node&) = delete;
- ~Node();
void join(int known_id);
void leave();
void notifyAndQuit();