// ***** Class definitions
namespace simgrid {
-namespace simix {
+namespace kernel {
+namespace context {
class RawContext;
class RawContextFactory;
friend class RawContextFactory;
RawContext(std::function<void()> code,
void_pfn_smxprocess_t cleanup_func,
- smx_process_t process);
+ smx_actor_t process);
~RawContext() override;
public:
static void wrapper(void* arg);
RawContextFactory();
~RawContextFactory() override;
RawContext* create_context(std::function<void()> code,
- void_pfn_smxprocess_t cleanup, smx_process_t process) override;
+ void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
void run_all() override;
private:
void run_all_adaptative();
return new RawContextFactory();
}
-}
-}
+}}} // namespace
// ***** Loads of static stuff
#if HAVE_THREAD_CONTEXTS
static xbt_parmap_t raw_parmap;
-static simgrid::simix::RawContext** raw_workers_context; /* space to save the worker context in each thread */
+static simgrid::kernel::context::RawContext** raw_workers_context; /* space to save the worker context in each thread */
static uintptr_t raw_threads_working; /* number of threads that have started their work */
static xbt_os_thread_key_t raw_worker_id_key; /* thread-specific storage for the thread id */
#endif
static unsigned long raw_process_index = 0; /* index of the next process to run in the
* list of runnable processes */
-static simgrid::simix::RawContext* raw_maestro_context;
+static simgrid::kernel::context::RawContext* raw_maestro_context;
static bool raw_context_parallel = false;
// ***** Method definitions
namespace simgrid {
-namespace simix {
+namespace kernel {
+namespace context {
RawContextFactory::RawContextFactory()
: ContextFactory("RawContextFactory")
}
RawContext* RawContextFactory::create_context(std::function<void()> code,
- void_pfn_smxprocess_t cleanup, smx_process_t process)
+ void_pfn_smxprocess_t cleanup, smx_actor_t process)
{
return this->new_context<RawContext>(std::move(code),
cleanup, process);
}
RawContext::RawContext(std::function<void()> code,
- void_pfn_smxprocess_t cleanup, smx_process_t process)
+ void_pfn_smxprocess_t cleanup, smx_actor_t process)
: Context(std::move(code), cleanup, process)
{
if (has_code()) {
void RawContextFactory::run_all_serial()
{
- smx_process_t first_process =
- xbt_dynar_get_as(simix_global->process_to_run, 0, smx_process_t);
+ if (xbt_dynar_is_empty(simix_global->process_to_run))
+ return;
+
+ smx_actor_t first_process =
+ xbt_dynar_get_as(simix_global->process_to_run, 0, smx_actor_t);
raw_process_index = 1;
static_cast<RawContext*>(first_process->context)->resume_serial();
}
SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
xbt_parmap_apply(raw_parmap,
[](void* arg) {
- smx_process_t process = static_cast<smx_process_t>(arg);
+ smx_actor_t process = static_cast<smx_actor_t>(arg);
RawContext* context = static_cast<RawContext*>(process->context);
context->resume_parallel();
},
/* execute the next process */
XBT_DEBUG("Run next process");
next_context = (RawContext*) xbt_dynar_get_as(
- simix_global->process_to_run, i, smx_process_t)->context;
+ simix_global->process_to_run, i, smx_actor_t)->context;
}
else {
/* all processes were run, return to maestro */
{
#if HAVE_THREAD_CONTEXTS
/* determine the next context */
- smx_process_t next_work = (smx_process_t) xbt_parmap_next(raw_parmap);
+ smx_actor_t next_work = (smx_actor_t) xbt_parmap_next(raw_parmap);
RawContext* next_context = nullptr;
if (next_work != nullptr) {
}
}
-}
-}
+}}}