namespace kernel {
namespace context {
-/* Sequential execution */
-unsigned long SwappedContext::process_index_;
-
/* Parallel execution */
simgrid::xbt::Parmap<smx_actor_t>* SwappedContext::parmap_;
std::atomic<uintptr_t> SwappedContext::threads_working_; /* number of threads that have started their work */
} else { // sequential execution
if (simix_global->process_to_run.empty())
return;
- smx_actor_t first_process = simix_global->process_to_run.front();
- SwappedContext::process_index_ = 1;
- /* execute the first process */
- static_cast<SwappedContext*>(first_process->context_)->resume();
+ smx_actor_t first_actor = simix_global->process_to_run.front();
+ process_index_ = 1;
+ /* execute the first actor; it will chain to the others when using suspend() */
+ static_cast<SwappedContext*>(first_actor->context_)->resume();
}
}
} else { // sequential execution
/* determine the next context */
SwappedContext* next_context;
- unsigned long int i = process_index_;
- process_index_++;
+ unsigned long int i = factory_->process_index_;
+ factory_->process_index_++;
if (i < simix_global->process_to_run.size()) {
/* Actually swap into the next actor directly without transiting to maestro */
~SwappedContextFactory() override;
void run_all() override;
-protected: // FIXME temporary internal exposure
+protected:
bool parallel_;
+
+private:
+ unsigned long process_index_ = 0; // Next actor to execute during sequential run_all()
};
class SwappedContext : public Context {
static SwappedContext* get_maestro() { return maestro_context_; }
static void set_maestro(SwappedContext* maestro) { maestro_context_ = maestro; }
- static unsigned long process_index_; // FIXME killme
-
- /* For the parallel execution */
+ /* For the parallel execution */ // FIXME killme
static simgrid::xbt::Parmap<smx_actor_t>* parmap_;
static std::vector<SwappedContext*> workers_context_;
static std::atomic<uintptr_t> threads_working_;