p Test1 MSG_comm_test() with Sleep_sender > Sleep_receiver
-! output sort 19
$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
> [ 1.000000] (2:receiver@Ruby) Wait to receive a task
> [ 5.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
-> [ 5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.100000] (2:receiver@Ruby) Received "Task_0"
> [ 5.100000] (2:receiver@Ruby) Processing "Task_0"
+> [ 5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.609710] (2:receiver@Ruby) "Task_0" done
> [ 5.609710] (2:receiver@Ruby) Wait to receive a task
> [ 5.700000] (1:sender@Tremblay) Send to receiver-0 Task_2
> [ 6.829130] (2:receiver@Ruby) "Task_2" done
> [ 6.829130] (2:receiver@Ruby) Wait to receive a task
> [ 6.900000] (1:sender@Tremblay) Goodbye now!
-> [ 6.929130] (0:maestro@) Simulation time 6.92913
> [ 6.929130] (2:receiver@Ruby) Received "finalize"
> [ 6.929130] (2:receiver@Ruby) I'm done. See you!
+> [ 6.929130] (0:maestro@) Simulation time 6.92913
p Test2 MSG_comm_test() with Sleep_sender < Sleep_receiver
-! output sort 19
$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
> [ 1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
> [ 5.000000] (2:receiver@Ruby) Wait to receive a task
-> [ 5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.100000] (2:receiver@Ruby) Received "Task_0"
> [ 5.100000] (2:receiver@Ruby) Processing "Task_0"
+> [ 5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.609710] (2:receiver@Ruby) "Task_0" done
> [ 5.609710] (2:receiver@Ruby) Wait to receive a task
> [ 5.700000] (1:sender@Tremblay) Send to receiver-0 Task_2
> [ 6.829130] (2:receiver@Ruby) "Task_2" done
> [ 6.829130] (2:receiver@Ruby) Wait to receive a task
> [ 6.900000] (1:sender@Tremblay) Goodbye now!
-> [ 6.929130] (0:maestro@) Simulation time 6.92913
> [ 6.929130] (2:receiver@Ruby) Received "finalize"
> [ 6.929130] (2:receiver@Ruby) I'm done. See you!
+> [ 6.929130] (0:maestro@) Simulation time 6.92913
p Test1 MSG_comm_wait() with Sleep_sender > Sleep_receiver
-! output sort 19
$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
> [ 1.000000] (2:receiver@Ruby) Wait to receive a task
> [ 5.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
-> [ 5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.004022] (2:receiver@Ruby) Received "Task_0"
> [ 5.004022] (2:receiver@Ruby) Processing "Task_0"
+> [ 5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.513732] (2:receiver@Ruby) "Task_0" done
> [ 5.513732] (2:receiver@Ruby) Wait to receive a task
-> [ 5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
> [ 5.517753] (2:receiver@Ruby) Received "Task_1"
> [ 5.517753] (2:receiver@Ruby) Processing "Task_1"
+> [ 5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
> [ 6.027463] (2:receiver@Ruby) "Task_1" done
> [ 6.027463] (2:receiver@Ruby) Wait to receive a task
-> [ 6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
> [ 6.031485] (2:receiver@Ruby) Received "Task_2"
> [ 6.031485] (2:receiver@Ruby) Processing "Task_2"
+> [ 6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
> [ 6.541195] (2:receiver@Ruby) "Task_2" done
> [ 6.541195] (2:receiver@Ruby) Wait to receive a task
-> [ 6.543146] (0:maestro@) Simulation time 6.54315
> [ 6.543146] (1:sender@Tremblay) Goodbye now!
> [ 6.543146] (2:receiver@Ruby) Received "finalize"
> [ 6.543146] (2:receiver@Ruby) I'm done. See you!
+> [ 6.543146] (0:maestro@) Simulation time 6.54315
p Test2 MSG_comm_wait() with Sleep_sender < Sleep_receiver
-! output sort 19
$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
> [ 1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
> [ 5.000000] (2:receiver@Ruby) Wait to receive a task
-> [ 5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.004022] (2:receiver@Ruby) Received "Task_0"
> [ 5.004022] (2:receiver@Ruby) Processing "Task_0"
+> [ 5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
> [ 5.513732] (2:receiver@Ruby) "Task_0" done
> [ 5.513732] (2:receiver@Ruby) Wait to receive a task
-> [ 5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
> [ 5.517753] (2:receiver@Ruby) Received "Task_1"
> [ 5.517753] (2:receiver@Ruby) Processing "Task_1"
+> [ 5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
> [ 6.027463] (2:receiver@Ruby) "Task_1" done
> [ 6.027463] (2:receiver@Ruby) Wait to receive a task
-> [ 6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
> [ 6.031485] (2:receiver@Ruby) Received "Task_2"
> [ 6.031485] (2:receiver@Ruby) Processing "Task_2"
+> [ 6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
> [ 6.541195] (2:receiver@Ruby) "Task_2" done
> [ 6.541195] (2:receiver@Ruby) Wait to receive a task
-> [ 6.543146] (0:maestro@) Simulation time 6.54315
> [ 6.543146] (1:sender@Tremblay) Goodbye now!
> [ 6.543146] (2:receiver@Ruby) Received "finalize"
> [ 6.543146] (2:receiver@Ruby) I'm done. See you!
+> [ 6.543146] (0:maestro@) Simulation time 6.54315
#include "s4u/engine.hpp"
#include "s4u/host.hpp"
-#include "s4u/async.hpp"
+#include "s4u/Activity.hpp"
#include "s4u/comm.hpp"
#include "s4u/storage.hpp"
/* 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. */
-#ifndef SIMGRID_S4U_ASYNC_HPP
-#define SIMGRID_S4U_ASYNC_HPP
+#ifndef SIMGRID_S4U_ACTIVITY_HPP
+#define SIMGRID_S4U_ACTIVITY_HPP
#include <stdlib.h>
#include <xbt/base.h>
SG_BEGIN_DECL();
typedef enum {
inited, started, finished
-} e_s4u_async_state_t;
+} e_s4u_activity_state_t;
SG_END_DECL();
namespace simgrid {
namespace s4u {
-/** @brief Asynchronous Actions
+/** @brief Activities
*
- * This class is the ancestor of every asynchronous actions, that is, of actions that do take time in the simulated world.
+ * This class is the ancestor of every activities that an actor can undertake, that is, of the actions that do take time in the simulated world.
*/
-XBT_PUBLIC_CLASS Async {
+XBT_PUBLIC_CLASS Activity {
friend Comm;
protected:
- Async();
- virtual ~Async();
+ Activity();
+ virtual ~Activity();
private:
simgrid::simix::Synchro *pimpl_ = NULL;
private:
- e_s4u_async_state_t state_ = inited;
+ e_s4u_activity_state_t state_ = inited;
public:
- /** Starts a previously created async.
+ /** Starts a previously created activity.
*
* This function is optional: you can call wait() even if you didn't call start()
*/
virtual void start()=0;
- /** Tests whether the given async is terminated yet */
+ /** Tests whether the given activity is terminated yet. This is a pure function. */
//virtual bool test()=0;
- /** Blocks until the async is terminated */
+ /** Blocks until the activity is terminated */
virtual void wait()=0;
- /** Blocks until the async is terminated, or until the timeout is elapsed
+ /** Blocks until the activity is terminated, or until the timeout is elapsed
* Raises: timeout exception.*/
virtual void wait(double timeout)=0;
- /** Cancel that async */
+ /** Cancel that activity */
//virtual void cancel();
- /** Retrieve the current state of the async */
- e_s4u_async_state_t getState() {return state_;}
+ /** Retrieve the current state of the activity */
+ e_s4u_activity_state_t getState() {return state_;}
private:
double remains_ = 0;
public:
- /** Get the remaining amount of work that this Async entails. When it's 0, it's done. */
+ /** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */
double getRemains();
- /** Set the [remaining] amount of work that this Async will entail
+ /** Set the [remaining] amount of work that this Activity will entail
*
- * It is forbidden to change the amount of work once the Async is started */
+ * It is forbidden to change the amount of work once the Activity is started */
void setRemains(double remains);
private:
void *userData_ = NULL;
public:
- /** Put some user data onto the Async */
+ /** Put some user data onto the Activity */
void setUserData(void *data) {userData_=data;}
- /** Retrieve the user data of the Async */
+ /** Retrieve the user data of the Activity */
void *getUserData() { return userData_; }
}; // class
}}; // Namespace simgrid::s4u
-#endif /* SIMGRID_S4U_ASYNC_HPP */
+#endif /* SIMGRID_S4U_ACTIVITY_HPP */
#define SIMGRID_S4U_COMM_HPP
#include <xbt/base.h>
+#include <simgrid/s4u/Activity.hpp>
#include <simgrid/s4u/forward.hpp>
-#include <simgrid/s4u/async.hpp>
#include <simgrid/s4u/mailbox.hpp>
namespace simgrid {
*
* Represents all asynchronous communications, that you can test or wait onto.
*/
-XBT_PUBLIC_CLASS Comm : public Async {
- Comm() : Async() {}
+XBT_PUBLIC_CLASS Comm : public Activity {
+ Comm() : Activity() {}
public:
virtual ~Comm();
namespace simgrid {
namespace s4u {
-class Async;
+class Activity;
class Comm;
class Engine;
class Host;
#include "xbt/log.h"
#include "src/msg/msg_private.h"
-#include "simgrid/s4u/async.hpp"
+#include "simgrid/s4u/Activity.hpp"
XBT_LOG_EXTERNAL_CATEGORY(s4u);
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_async,s4u,"S4U asynchronous actions");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity,s4u,"S4U activities");
using namespace simgrid;
-s4u::Async::Async() {
+s4u::Activity::Activity() {
}
-s4u::Async::~Async() {
+s4u::Activity::~Activity() {
}
-void s4u::Async::setRemains(double remains) {
- xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Async is started");
+void s4u::Activity::setRemains(double remains) {
+ xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Activity is started");
remains_ = remains;
}
#include "simgrid/s4u/comm.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm,s4u_async,"S4U asynchronous communications");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm,s4u_activity,"S4U asynchronous communications");
using namespace simgrid;
s4u::Comm::~Comm() {
~Comm();
public:
Comm(e_smx_comm_type_t type);
- void suspend();
- void resume();
+ void suspend() override;
+ void resume() override;
void post() override;
void cancel();
double remains();
XBT_PUBLIC_CLASS Exec : public Synchro {
~Exec();
public:
- void suspend();
- void resume();
+ void suspend() override;
+ void resume() override;
void post() override;
double remains();
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
+simgrid::simix::Raw::~Raw()
+{
+ sleep->unref();
+}
void simgrid::simix::Raw::suspend()
{
/* The suspension of raw synchros is delayed to when the process is rescheduled. */
/** Used to implement mutexes, semaphores and conditions */
XBT_PUBLIC_CLASS Raw : public Synchro {
public:
- void suspend();
- void resume();
+ ~Raw();
+ void suspend() override;
+ void resume() override;
void post() override;
surf_action_t sleep;
XBT_PUBLIC_CLASS Sleep : public Synchro {
public:
- void suspend();
- void resume();
+ void suspend() override;
+ void resume() override;
void post() override;
sg_host_t host; /* The host that is sleeping */
SIMIX_execution_finish(exec);
}
-void SIMIX_execution_suspend(smx_synchro_t synchro)
-{
- synchro->suspend(); // FIXME: USELESS
-}
-
-void SIMIX_execution_resume(smx_synchro_t synchro)
-{
- synchro->resume(); // FIXME: USELESS
-}
-
void SIMIX_execution_finish(simgrid::simix::Exec *exec)
{
xbt_fifo_item_t item;
XBT_PRIVATE void SIMIX_execution_set_bound(smx_synchro_t synchro, double bound);
XBT_PRIVATE void SIMIX_execution_set_affinity(smx_synchro_t synchro, sg_host_t host, unsigned long mask);
-XBT_PRIVATE void SIMIX_execution_suspend(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_execution_resume(smx_synchro_t synchro);
XBT_PRIVATE void SIMIX_execution_finish(simgrid::simix::Exec *exec);
XBT_PRIVATE void SIMIX_set_category(smx_synchro_t synchro, const char *category);
void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_process_t process)
{
- smx_synchro_t sync_suspend =
- SIMIX_process_suspend(process, simcall->issuer);
+ smx_synchro_t sync_suspend = SIMIX_process_suspend(process, simcall->issuer);
if (process != simcall->issuer) {
SIMIX_simcall_answer(simcall);
} else {
xbt_fifo_push(sync_suspend->simcalls, simcall);
process->waiting_synchro = sync_suspend;
- SIMIX_execution_suspend(process->waiting_synchro);
+ process->waiting_synchro->suspend();
}
/* If we are suspending ourselves, then just do not finish the simcall now */
}
XBT_DEBUG("Destroying synchro %p", synchro);
simgrid::simix::Raw *raw = static_cast<simgrid::simix::Raw*>(synchro);
- raw->sleep->unref();
delete raw;
}
set(S4U_SRC
src/s4u/s4u_actor.cpp
src/s4u/s4u_as.cpp
- src/s4u/s4u_async.cpp
+ src/s4u/s4u_activity.cpp
src/s4u/s4u_comm.cpp
src/s4u/s4u_engine.cpp
src/s4u/s4u_file.cpp
include/simgrid/s4u/forward.hpp
include/simgrid/s4u/actor.hpp
include/simgrid/s4u/As.hpp
- include/simgrid/s4u/async.hpp
+ include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/comm.hpp
include/simgrid/s4u/engine.hpp
include/simgrid/s4u/file.hpp