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
woops, plug a memleak
[simgrid.git]
/
src
/
kernel
/
context
/
ContextThread.cpp
diff --git
a/src/kernel/context/ContextThread.cpp
b/src/kernel/context/ContextThread.cpp
index
c93e361
..
b78153f
100644
(file)
--- a/
src/kernel/context/ContextThread.cpp
+++ b/
src/kernel/context/ContextThread.cpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2009-201
8
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-201
9
. The SimGrid Team. All rights reserved. */
/* 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. */
/* 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. */
@@
-63,35
+63,29
@@
ThreadContext::ThreadContext(std::function<void()> code, void_pfn_smxprocess_t c
{
/* If the user provided a function for the process then use it */
if (has_code()) {
{
/* If the user provided a function for the process then use it */
if (has_code()) {
- if (smx_context_stack_size_was_set)
- xbt_os_thread_setstacksize(smx_context_stack_size);
- if (smx_context_guard_size_was_set)
- xbt_os_thread_setguardsize(smx_context_guard_size);
-
/* create and start the process */
/* create and start the process */
- /* NOTE: The first argument to xbt_os_thread_create used to be the process *
- * name, but now the name is stored at SIMIX level, so we pass a null */
- this->thread_ = xbt_os_thread_create(nullptr, ThreadContext::wrapper, this, this);
+ this->thread_ = new std::thread(ThreadContext::wrapper, this);
/* wait the starting of the newly created process */
this->end_.acquire();
}
/* Otherwise, we attach to the current thread */
else {
/* wait the starting of the newly created process */
this->end_.acquire();
}
/* Otherwise, we attach to the current thread */
else {
-
SIMIX_context_
set_current(this);
+
Context::
set_current(this);
}
}
ThreadContext::~ThreadContext()
{
if (this->thread_) /* If there is a thread (maestro don't have any), wait for its termination */
}
}
ThreadContext::~ThreadContext()
{
if (this->thread_) /* If there is a thread (maestro don't have any), wait for its termination */
- xbt_os_thread_join(this->thread_, nullptr);
+ thread_->join();
+ delete thread_;
}
void *ThreadContext::wrapper(void *param)
{
ThreadContext* context = static_cast<ThreadContext*>(param);
}
void *ThreadContext::wrapper(void *param)
{
ThreadContext* context = static_cast<ThreadContext*>(param);
-
SIMIX_context_
set_current(context);
+
Context::
set_current(context);
#ifndef WIN32
/* Install alternate signal stack, for SIGSEGV handler. */
#ifndef WIN32
/* Install alternate signal stack, for SIGSEGV handler. */
@@
-178,7
+172,7
@@
void ThreadContext::attach_stop()
ThreadContext* maestro = (ThreadContext*)simix_global->maestro_process->context_;
maestro->end_.acquire();
ThreadContext* maestro = (ThreadContext*)simix_global->maestro_process->context_;
maestro->end_.acquire();
-
SIMIX_context_
set_current(nullptr);
+
Context::
set_current(nullptr);
}
// SerialThreadContext
}
// SerialThreadContext