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
[simix] Use std::function for the maestro callback instead of void(void*)
[simgrid.git]
/
src
/
simix
/
smx_global.cpp
diff --git
a/src/simix/smx_global.cpp
b/src/simix/smx_global.cpp
index
080e606
..
10fbceb
100644
(file)
--- a/
src/simix/smx_global.cpp
+++ b/
src/simix/smx_global.cpp
@@
-175,13
+175,22
@@
static void SIMIX_storage_create_(smx_storage_t storage)
SIMIX_storage_create(key, storage, NULL);
}
SIMIX_storage_create(key, storage, NULL);
}
-static void (*maestro_code)(void*) = nullptr;
-static void* maestro_data = nullptr;
+static std::function<void()> maestro_code;
+
+namespace simgrid {
+namespace simix {
+
+XBT_PUBLIC(void) set_maestro(std::function<void()> code)
+{
+ maestro_code = std::move(code);
+}
+
+}
+}
void SIMIX_set_maestro(void (*code)(void*), void* data)
{
void SIMIX_set_maestro(void (*code)(void*), void* data)
{
- maestro_code = code;
- maestro_data = data;
+ maestro_code = std::bind(code, data);
}
/**
}
/**
@@
-230,7
+239,7
@@
void SIMIX_global_init(int *argc, char **argv)
// Either create a new context with maestro or create
// a context object with the current context mestro):
// Either create a new context with maestro or create
// a context object with the current context mestro):
-
SIMIX_maestro_create(maestro_code, maestro_data
);
+
simgrid::simix::create_maestro(maestro_code
);
/* context exception handlers */
__xbt_running_ctx_fetch = SIMIX_process_get_running_context;
/* context exception handlers */
__xbt_running_ctx_fetch = SIMIX_process_get_running_context;