XBT_PUBLIC void sg_actor_kill_all();
XBT_PUBLIC void sg_actor_set_kill_time(sg_actor_t actor, double kill_time);
XBT_PUBLIC void sg_actor_yield();
+XBT_PUBLIC void sg_actor_sleep_for(double duration);
SG_END_DECL()
#endif /* INCLUDE_SIMGRID_ACTOR_H_ */
XBT_PUBLIC void MSG_process_set_kill_time(msg_process_t process, double kill_time);
/** @brief Yield the current actor; let the other actors execute first */
XBT_PUBLIC void MSG_process_yield();
+/*** @brief Sleep for the specified number of seconds */
+XBT_PUBLIC void MSG_process_sleep(double nb_sec);
/** @brief Object representing an ongoing communication between processes.
*
XBT_PUBLIC void MSG_task_set_priority(msg_task_t task, double priority);
XBT_PUBLIC void MSG_task_set_bound(msg_task_t task, double bound);
-XBT_PUBLIC msg_error_t MSG_process_sleep(double nb_sec);
-
XBT_PUBLIC void MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
XBT_PUBLIC double MSG_task_get_flops_amount(msg_task_t task);
XBT_PUBLIC double MSG_task_get_remaining_work_ratio(msg_task_t task);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
{
double time = ((double)jmillis) / 1000 + ((double)jnanos) / 1000000000;
- msg_error_t rv;
- if (not simgrid::kernel::context::StopRequest::try_n_catch([&rv, &time]() { rv = MSG_process_sleep(time); })) {
+ msg_error_t rv = MSG_OK;
+ if (not simgrid::kernel::context::StopRequest::try_n_catch(
+ [&time]() { simgrid::s4u::this_actor::sleep_for(time); })) {
rv = MSG_HOST_FAILURE;
}
if (rv != MSG_OK) {
- XBT_DEBUG("Something during the MSG_process_sleep invocation was wrong, trigger a HostFailureException");
-
- jxbt_throw_host_failure(env, "");
+ jmsg_throw_status(env, rv);
}
}
return status;
}
-/**
- * @brief Sleep for the specified number of seconds
- *
- * Makes the current process sleep until @a time seconds have elapsed.
- *
- * @param nb_sec a number of second
- */
-msg_error_t MSG_process_sleep(double nb_sec)
-{
- msg_error_t status = MSG_OK;
-
- try {
- simgrid::s4u::this_actor::sleep_for(nb_sec);
- } catch (simgrid::HostFailureException& e) {
- status = MSG_HOST_FAILURE;
- } catch (xbt_ex& e) {
- if (e.category == cancel_error) {
- XBT_DEBUG("According to the JAVA API, a sleep call should only deal with HostFailureException, I'm lost.");
- // adsein: MSG_TASK_CANCELED is assigned when someone kills the process that made the sleep, this is not
- // correct. For instance, when the node is turned off, the error should be MSG_HOST_FAILURE, which is by the way
- // and according to the JAVA document, the only exception that can be triggered by MSG_Process_sleep call.
- // To avoid possible impacts in the code, I just raised a host_failure exception for the moment in the JAVA code
- // and did not change anythings at the C level.
- // See comment in the jmsg_process.c file, function JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
- status = MSG_TASK_CANCELED;
- } else
- throw;
- }
-
- return status;
-}
-
/**
* @brief Receives a task from a mailbox.
*
{
sg_actor_yield();
}
-
+void MSG_process_sleep(double duration)
+{
+ sg_actor_sleep_for(duration);
+}
/* ************************** NetZones *************************** */
sg_netzone_t MSG_zone_get_root()
{
{
simgrid::s4u::this_actor::yield();
}
+
+void sg_actor_sleep_for(double duration)
+{
+ simgrid::s4u::this_actor::sleep_for(duration);
+}