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
please clang
[simgrid.git]
/
src
/
simix
/
ActorImpl.cpp
diff --git
a/src/simix/ActorImpl.cpp
b/src/simix/ActorImpl.cpp
index
a0e300d
..
469386d
100644
(file)
--- a/
src/simix/ActorImpl.cpp
+++ b/
src/simix/ActorImpl.cpp
@@
-133,7
+133,7
@@
void SIMIX_process_cleanup(smx_actor_t process)
}
XBT_DEBUG("%p should not be run anymore",process);
}
XBT_DEBUG("%p should not be run anymore",process);
-
xbt_swag_remove(process, simix_global->process_list
);
+
simix_global->process_list.erase(process->pid
);
if (process->host)
xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
xbt_swag_insert(process, simix_global->process_to_destroy);
if (process->host)
xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
xbt_swag_insert(process, simix_global->process_to_destroy);
@@
-175,7
+175,7
@@
ActorImpl::~ActorImpl()
void create_maestro(std::function<void()> code)
{
smx_actor_t maestro = nullptr;
void create_maestro(std::function<void()> code)
{
smx_actor_t maestro = nullptr;
- /* Create maestro process and in
til
ialize it */
+ /* Create maestro process and in
it
ialize it */
maestro = new simgrid::simix::ActorImpl();
maestro->pid = simix_process_maxpid++;
maestro->ppid = -1;
maestro = new simgrid::simix::ActorImpl();
maestro->pid = simix_process_maxpid++;
maestro->ppid = -1;
@@
-279,7
+279,7
@@
smx_actor_t SIMIX_process_create(
XBT_DEBUG("Start context '%s'", process->name.c_str());
/* Now insert it in the global process list and in the process to run list */
XBT_DEBUG("Start context '%s'", process->name.c_str());
/* Now insert it in the global process list and in the process to run list */
-
xbt_swag_insert(process, simix_global->process_list)
;
+
simix_global->process_list[process->pid] = process
;
XBT_DEBUG("Inserting %s(%s) in the to_run list", process->cname(), host->cname());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
XBT_DEBUG("Inserting %s(%s) in the to_run list", process->cname(), host->cname());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
@@
-357,7
+357,7
@@
smx_actor_t SIMIX_process_attach(
xbt_swag_insert(process, sg_host_simix(host)->process_list);
/* Now insert it in the global process list and in the process to run list */
xbt_swag_insert(process, sg_host_simix(host)->process_list);
/* Now insert it in the global process list and in the process to run list */
-
xbt_swag_insert(process, simix_global->process_list)
;
+
simix_global->process_list[process->pid] = process
;
XBT_DEBUG("Inserting %s(%s) in the to_run list", process->cname(), host->cname());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
XBT_DEBUG("Inserting %s(%s) in the to_run list", process->cname(), host->cname());
xbt_dynar_push_as(simix_global->process_to_run, smx_actor_t, process);
@@
-540,13
+540,9
@@
void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid) {
*/
void SIMIX_process_killall(smx_actor_t issuer, int reset_pid)
{
*/
void SIMIX_process_killall(smx_actor_t issuer, int reset_pid)
{
- smx_actor_t p = nullptr;
-
- while ((p = (smx_actor_t) xbt_swag_extract(simix_global->process_list))) {
- if (p != issuer) {
- SIMIX_process_kill(p,issuer);
- }
- }
+ for (auto kv : simix_global->process_list)
+ if (kv.second != issuer)
+ SIMIX_process_kill(kv.second, issuer);
if (reset_pid > 0)
simix_process_maxpid = reset_pid;
if (reset_pid > 0)
simix_process_maxpid = reset_pid;
@@
-630,7
+626,7
@@
int SIMIX_process_get_maxpid() {
int SIMIX_process_count()
{
int SIMIX_process_count()
{
- return
xbt_swag_size(simix_global->process_list
);
+ return
simix_global->process_list.size(
);
}
int SIMIX_process_get_PID(smx_actor_t self)
}
int SIMIX_process_get_PID(smx_actor_t self)
@@
-681,11
+677,9
@@
const char* SIMIX_process_self_get_name() {
smx_actor_t SIMIX_process_get_by_name(const char* name)
{
smx_actor_t SIMIX_process_get_by_name(const char* name)
{
- smx_actor_t proc;
- xbt_swag_foreach(proc, simix_global->process_list) {
- if (proc->name == name)
- return proc;
- }
+ for (auto kv : simix_global->process_list)
+ if (kv.second->name == name)
+ return kv.second;
return nullptr;
}
return nullptr;
}
@@
-797,7
+791,7
@@
void SIMIX_process_sleep_destroy(smx_activity_t synchro)
*/
void SIMIX_process_yield(smx_actor_t self)
{
*/
void SIMIX_process_yield(smx_actor_t self)
{
- XBT_DEBUG("Yield
process '%s'", self->name.c_str
());
+ XBT_DEBUG("Yield
actor '%s'", self->cname
());
/* Go into sleep and return control to maestro */
self->context->suspend();
/* Go into sleep and return control to maestro */
self->context->suspend();
@@
-874,19
+868,16
@@
xbt_dynar_t SIMIX_process_get_runnable()
*/
smx_actor_t SIMIX_process_from_PID(int PID)
{
*/
smx_actor_t SIMIX_process_from_PID(int PID)
{
- smx_actor_t proc;
- xbt_swag_foreach(proc, simix_global->process_list) {
- if (proc->pid == static_cast<unsigned long> (PID))
- return proc;
- }
- return nullptr;
+ if (simix_global->process_list.find(PID) == simix_global->process_list.end())
+ return nullptr;
+ return simix_global->process_list.at(PID);
}
/** @brief returns a dynar containing all currently existing processes */
xbt_dynar_t SIMIX_processes_as_dynar() {
}
/** @brief returns a dynar containing all currently existing processes */
xbt_dynar_t SIMIX_processes_as_dynar() {
- smx_actor_t proc;
xbt_dynar_t res = xbt_dynar_new(sizeof(smx_actor_t),nullptr);
xbt_dynar_t res = xbt_dynar_new(sizeof(smx_actor_t),nullptr);
- xbt_swag_foreach(proc, simix_global->process_list) {
+ for (auto kv : simix_global->process_list) {
+ smx_actor_t proc = kv.second;
xbt_dynar_push(res,&proc);
}
return res;
xbt_dynar_push(res,&proc);
}
return res;
@@
-998,7
+989,7
@@
smx_actor_t simcall_process_create(
if (name == nullptr)
name = "";
smx_actor_t self = SIMIX_process_self();
if (name == nullptr)
name = "";
smx_actor_t self = SIMIX_process_self();
- return simgrid::simix::kernelImmediate([
&
] {
+ return simgrid::simix::kernelImmediate([
name, code, data, host, kill_time, properties, auto_restart, self
] {
return SIMIX_process_create(name, std::move(code), data, host, kill_time, properties, auto_restart, self);
});
}
return SIMIX_process_create(name, std::move(code), data, host, kill_time, properties, auto_restart, self);
});
}