From 6ba3cca6077ef2266bfbb7319435bf6dee143b91 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Mon, 4 Jan 2016 14:34:53 +0100 Subject: [PATCH] [simix] Add assertion in run_kernel --- include/simgrid/simix.h | 2 +- include/simgrid/simix.hpp | 1 + src/simix/smx_global.cpp | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 2c8bdf4f70..0e3117d708 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -167,7 +167,7 @@ XBT_PUBLIC(int) SIMIX_context_get_parallel_threshold(void); XBT_PUBLIC(void) SIMIX_context_set_parallel_threshold(int threshold); XBT_PUBLIC(e_xbt_parmap_mode_t) SIMIX_context_get_parallel_mode(void); XBT_PUBLIC(void) SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode); - +XBT_PUBLIC(int) SIMIX_is_maestro(); /********************************** Global ************************************/ diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 0cdf6ea490..8dc10836e1 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -55,6 +55,7 @@ typename std::result_of::type kernel(F&& code) typedef typename std::result_of::type R; std::promise promise; simcall_run_kernel([&]{ + xbt_assert(SIMIX_is_maestro(), "Not in maestro"); fulfill_promise(promise, code); }); return promise.get_future().get(); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 3ba0e93a5d..1da0f27af6 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -698,3 +698,8 @@ xbt_dict_t SIMIX_asr_get_properties(const char *name) { return (xbt_dict_t) xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL); } + +int SIMIX_is_maestro() +{ + return SIMIX_process_self() == simix_global->maestro_process; +} \ No newline at end of file -- 2.20.1