2012-03-29 17:21:32 -05:00
|
|
|
#ifndef RUST_SCHED_LAUNCHER_H
|
|
|
|
#define RUST_SCHED_LAUNCHER_H
|
|
|
|
|
|
|
|
#include "sync/rust_thread.h"
|
2012-03-30 19:10:02 -05:00
|
|
|
#include "rust_sched_driver.h"
|
2012-04-02 22:18:01 -05:00
|
|
|
#include "rust_kernel.h"
|
|
|
|
#include "rust_sched_loop.h"
|
2012-03-29 17:21:32 -05:00
|
|
|
|
2012-04-01 00:00:08 -05:00
|
|
|
class rust_sched_launcher : public kernel_owned<rust_sched_launcher> {
|
2012-03-29 17:21:32 -05:00
|
|
|
public:
|
|
|
|
rust_kernel *kernel;
|
|
|
|
|
|
|
|
private:
|
2012-03-29 18:31:30 -05:00
|
|
|
rust_sched_loop sched_loop;
|
2012-04-01 00:00:08 -05:00
|
|
|
|
|
|
|
protected:
|
2012-03-30 19:10:02 -05:00
|
|
|
rust_sched_driver driver;
|
2012-03-29 17:21:32 -05:00
|
|
|
|
|
|
|
public:
|
2012-04-01 22:18:40 -05:00
|
|
|
rust_sched_launcher(rust_scheduler *sched, int id);
|
2012-04-01 15:25:49 -05:00
|
|
|
virtual ~rust_sched_launcher() { }
|
2012-03-29 17:21:32 -05:00
|
|
|
|
2012-04-01 00:00:08 -05:00
|
|
|
virtual void start() = 0;
|
|
|
|
virtual void join() = 0;
|
2012-03-29 18:31:30 -05:00
|
|
|
rust_sched_loop *get_loop() { return &sched_loop; }
|
2012-03-29 17:21:32 -05:00
|
|
|
};
|
|
|
|
|
2012-04-01 00:00:08 -05:00
|
|
|
class rust_thread_sched_launcher
|
|
|
|
:public rust_sched_launcher,
|
|
|
|
private rust_thread {
|
|
|
|
public:
|
2012-04-01 22:18:40 -05:00
|
|
|
rust_thread_sched_launcher(rust_scheduler *sched, int id);
|
2012-04-01 00:00:08 -05:00
|
|
|
virtual void start() { rust_thread::start(); }
|
|
|
|
virtual void join() { rust_thread::join(); }
|
2012-04-01 18:21:48 -05:00
|
|
|
virtual void run() { driver.start_main_loop(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class rust_manual_sched_launcher : public rust_sched_launcher {
|
|
|
|
public:
|
2012-04-03 22:29:12 -05:00
|
|
|
rust_manual_sched_launcher(rust_scheduler *sched, int id);
|
2012-04-01 20:42:28 -05:00
|
|
|
virtual void start() { }
|
|
|
|
virtual void join() { }
|
|
|
|
rust_sched_driver *get_driver() { return &driver; };
|
2012-04-01 00:00:08 -05:00
|
|
|
};
|
|
|
|
|
2012-04-01 19:22:24 -05:00
|
|
|
class rust_sched_launcher_factory {
|
|
|
|
public:
|
|
|
|
virtual ~rust_sched_launcher_factory() { }
|
|
|
|
virtual rust_sched_launcher *
|
|
|
|
create(rust_scheduler *sched, int id) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class rust_thread_sched_launcher_factory
|
|
|
|
: public rust_sched_launcher_factory {
|
|
|
|
public:
|
|
|
|
virtual rust_sched_launcher *create(rust_scheduler *sched, int id);
|
|
|
|
};
|
|
|
|
|
2012-04-01 19:35:35 -05:00
|
|
|
class rust_manual_sched_launcher_factory
|
|
|
|
: public rust_sched_launcher_factory {
|
|
|
|
private:
|
|
|
|
rust_manual_sched_launcher *launcher;
|
|
|
|
public:
|
|
|
|
rust_manual_sched_launcher_factory() : launcher(NULL) { }
|
|
|
|
virtual rust_sched_launcher *create(rust_scheduler *sched, int id);
|
2012-04-01 20:42:28 -05:00
|
|
|
rust_sched_driver *get_driver() {
|
|
|
|
assert(launcher != NULL);
|
|
|
|
return launcher->get_driver();
|
|
|
|
}
|
2012-04-01 00:00:08 -05:00
|
|
|
};
|
|
|
|
|
2012-03-29 17:21:32 -05:00
|
|
|
#endif // RUST_SCHED_LAUNCHER_H
|