ecto
|
#include <scheduler.hpp>
Public Types | |
enum | State { INIT = 0, RUNNING, EXECUTING, STOPPING, FINI = -1, ERROR = -2 } |
Public Member Functions | |
scheduler (plasm_ptr p) | |
~scheduler () | |
bool | execute (unsigned num_iters=0) |
bool | prepare_jobs (unsigned num_iters=0) |
bool | run_job () |
bool | run (unsigned timeout_usec) |
bool | run () |
bool | running () const |
bool | executing () const |
void | stop () |
std::string | stats () const |
State | state () const |
Private Member Functions | |
State | state (State) |
void | execute_init (unsigned num_iteRelWithDebInfors) |
void | execute_iter (unsigned cur_iter, unsigned num_iters, std::size_t stack_idx) |
void | execute_fini () |
void | interrupt () |
void | compute_stack () |
Private Attributes | |
plasm_ptr | plasm_ |
ecto::graph::graph_t & | graph_ |
std::vector< ecto::graph::graph_t::vertex_descriptor > | stack_ |
profile::graph_stats_type | graphstats_ |
boost::asio::io_service | io_svc_ |
boost::mutex | mtx_ |
State | state_ |
Current state of the scheduler. More... | |
std::size_t | runners_ |
Current number of "runners" (threads calling a run method). More... | |
boost::signals2::connection | interrupt_connection |
bool | interrupted |
TODO: Doc this class. TODO: Need to share io_svc_ instances with other entities (schedulers+)?
Scheduler states. Values greater than 0 indicate a "running" state.
Enumerator | |
---|---|
INIT |
None of the execute*() methods have been called yet. |
RUNNING |
One of the execute*() methods was called and successfully completed the specified number of iterations. |
EXECUTING |
execute() is running, or jobs have been prepared and the specified number of iterations have not been completed. |
STOPPING |
stop() was called, but the scheduler has not stopped yet. |
FINI |
stop() completed, or one of the cell::process() calls returned ecto::QUIT and the scheduler is no longer running. |
ERROR |
One of the cell::process() calls returned an error or threw, and the scheduler is no longer running. |
|
explicit |
ecto::scheduler::~scheduler | ( | ) |
|
private |
Check plasm for correctness, configure it, activate it, then sort it topologically to populate stack_. This method is idempotent.
bool ecto::scheduler::execute | ( | unsigned | num_iters = 0 | ) |
Synchronously execute plasm for num_iters iterations.
[in] | num_iters | The number of iterations to execute the plasm. 0 indicates that the plasm should be executed until some cell::process() call returns ecto::QUIT. |
|
private |
|
private |
|
private |
|
inline |
|
private |
bool ecto::scheduler::prepare_jobs | ( | unsigned | num_iters = 0 | ) |
Prepare jobs for execution of a plasm over num_iters iterations. No actual work will be done without calling the run*() methods. This just fills up the io service queues with the jobs required for initialisation and execution of the plasm over the specified number of iterations.
[in] | num_iters | The number of iterations to execute the plasm. 0 indicates that the plasm should be executed until some cell::process() call returns ecto::QUIT. |
bool ecto::scheduler::run | ( | unsigned | timeout_usec | ) |
Run jobs in the calling thread for the specified number of microseconds, or until the io_service is depleted.
[in] | timeout_usec | The number of microsecs to run io_service jobs. |
bool ecto::scheduler::run | ( | ) |
Run jobs in the calling thread until the io_service is depleted.
bool ecto::scheduler::run_job | ( | ) |
Run one job in the calling thread of execution.
|
inline |
|
inline |
|
inlineprivate |
|
inline |
void ecto::scheduler::stop | ( | ) |
Stop the scheduler, and flush any jobs in the io_service.
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
Current number of "runners" (threads calling a run method).
|
private |
|
private |
Current state of the scheduler.