static void coordinator()
{
int CS_used = 0;
- const Message* m = nullptr;
std::queue<simgrid::s4u::Mailbox*> requests;
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("coordinator");
while (true) {
- m = static_cast<Message*>(mbox->get());
+ auto m = mbox->get_unique<Message>();
if (m->kind == Message::Kind::REQUEST) {
if (CS_used) {
XBT_INFO("CS already used. Queue the request.");
CS_used = 0;
}
}
- delete m;
}
}
XBT_INFO("Propositions changed : r=1, cs=0");
}
- const auto* grant = static_cast<Message*>(my_mailbox->get());
+ auto grant = my_mailbox->get_unique<Message>();
if ((id == 1) && (grant->kind == Message::Kind::GRANT)) {
cs = 1;
XBT_INFO("Propositions changed : r=0, cs=1");
}
- delete grant;
-
XBT_INFO("%d got the answer. Sleep a bit and release it", id);
simgrid::s4u::this_actor::sleep_for(1);