-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2021. 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
-std::thread::id root_id;
+const std::thread::id root_id = std::this_thread::get_id();
static void ensure_root_tid()
{
{
ensure_root_tid();
auto* payload = new std::string("some message");
- simgrid::s4u::Mailbox::by_name("some mailbox")->put((void*)payload, 10e8);
+ simgrid::s4u::Mailbox::by_name("some mailbox")->put(payload, 10e8);
}
static void receiver()
{
ensure_other_tid();
- const auto* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
+ simgrid::s4u::Mailbox::by_name("some mailbox")->get_unique<std::string>();
XBT_INFO("Task received");
- delete payload;
}
static void maestro(void* /* data */)
/** Main function */
int main(int argc, char* argv[])
{
- root_id = std::this_thread::get_id();
-
/* Specify which code should be executed by maestro on another thread, once this current thread is affected to an
* actor by the subsequent sg_actor_attach(). This must be done before the creation of the engine. */
SIMIX_set_maestro(maestro, nullptr);