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
test exec->cancel() and simplify another test
[simgrid.git]
/
examples
/
s4u
/
exec-async
/
s4u-exec-async.cpp
diff --git
a/examples/s4u/exec-async/s4u-exec-async.cpp
b/examples/s4u/exec-async/s4u-exec-async.cpp
index
fd841f4
..
cb11ce2
100644
(file)
--- a/
examples/s4u/exec-async/s4u-exec-async.cpp
+++ b/
examples/s4u/exec-async/s4u-exec-async.cpp
@@
-11,23
+11,35
@@
static void test(double computation_amount, double priority)
{
XBT_INFO("Hello! Execute %g flops with priority %g", computation_amount, priority);
simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
- activity->set
P
riority(priority);
+ activity->set
_p
riority(priority);
activity->start();
activity->wait();
XBT_INFO("Goodbye now!");
}
+static void test_cancel(double computation_amount)
+{
+ XBT_INFO("Hello! Execute %g flops, should take 1 second", computation_amount);
+ simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(computation_amount);
+ simgrid::s4u::this_actor::sleep_for(0.5);
+ XBT_INFO("I changed my mind, cancel!");
+ activity->cancel();
+
+ XBT_INFO("Goodbye now!");
+}
+
int main(int argc, char* argv[])
{
simgrid::s4u::Engine e(&argc, argv);
e.load_platform(argv[1]);
simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 1.0);
simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 2.0);
+ simgrid::s4u::Actor::create("test_cancel", simgrid::s4u::Host::by_name("Boivin"), test_cancel, 98.095e+07);
e.run();
- XBT_INFO("Simulation time %g", e.get
C
lock());
+ XBT_INFO("Simulation time %g", e.get
_c
lock());
return 0;
}