A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Sonar smells after last changes.
[simgrid.git]
/
teshsuite
/
s4u
/
actor-suspend
/
actor-suspend.cpp
diff --git
a/teshsuite/s4u/actor-suspend/actor-suspend.cpp
b/teshsuite/s4u/actor-suspend/actor-suspend.cpp
index
e157191
..
ed4d1ed
100644
(file)
--- a/
teshsuite/s4u/actor-suspend/actor-suspend.cpp
+++ b/
teshsuite/s4u/actor-suspend/actor-suspend.cpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2020
-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. */
/* 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. */
@@
-14,21
+14,23
@@
XBT_LOG_NEW_DEFAULT_CATEGORY(mwe, "Minimum Working Example");
XBT_LOG_NEW_DEFAULT_CATEGORY(mwe, "Minimum Working Example");
-simgrid::s4u::ActorPtr receiver;
-
class Receiver {
public:
void operator()() const
{
XBT_INFO("Starting.");
auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
class Receiver {
public:
void operator()() const
{
XBT_INFO("Starting.");
auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
- int data = *
(int*)mailbox->get
();
+ int data = *
mailbox->get<int>
();
XBT_INFO("Got %d at the end", data);
}
};
class Suspender {
XBT_INFO("Got %d at the end", data);
}
};
class Suspender {
+ const simgrid::s4u::ActorPtr& receiver;
+
public:
public:
+ explicit Suspender(const simgrid::s4u::ActorPtr& receiver) : receiver(receiver) {}
+
void operator()() const
{
XBT_INFO("Suspend the receiver...");
void operator()() const
{
XBT_INFO("Suspend the receiver...");
@@
-41,7
+43,7
@@
public:
XBT_INFO("Sending a message to the receiver...");
auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
XBT_INFO("Sending a message to the receiver...");
auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
-
int data
= 42;
+
static int data
= 42;
mailbox->put(&data, 4);
XBT_INFO("Done!");
mailbox->put(&data, 4);
XBT_INFO("Done!");
@@
-50,15
+52,16
@@
public:
int main(int argc, char** argv)
{
int main(int argc, char** argv)
{
-
const simgrid::s4u::Engine* engine = new simgrid::s4u::E
ngine(&argc, argv);
+
simgrid::s4u::Engine e
ngine(&argc, argv);
- engine
->
load_platform(argv[1]);
- simgrid::s4u::Host* host =
simgrid::s4u::Host::
by_name("Tremblay");
+ engine
.
load_platform(argv[1]);
+ simgrid::s4u::Host* host =
engine.host_
by_name("Tremblay");
- simgrid::s4u::Actor::create("Suspender", host, Suspender());
+ simgrid::s4u::ActorPtr receiver;
+ simgrid::s4u::Actor::create("Suspender", host, Suspender(receiver));
receiver = simgrid::s4u::Actor::create("Receiver", host, Receiver());
receiver = simgrid::s4u::Actor::create("Receiver", host, Receiver());
- engine
->
run();
+ engine
.
run();
return 0;
}
return 0;
}