start towards adding support for mutexes
[model-checker.git] / schedule.h
1 /** @file schedule.h
2  *      @brief Thread scheduler.
3  */
4
5 #ifndef __SCHEDULE_H__
6 #define __SCHEDULE_H__
7
8 #include <list>
9 #include "mymemory.h"
10
11 /* Forward declaration */
12 class Thread;
13
14 /** @brief The Scheduler class performs the mechanics of Thread execution
15  * scheduling. */
16 class Scheduler {
17 public:
18         Scheduler();
19         void add_thread(Thread *t);
20         void remove_thread(Thread *t);
21         void sleep(Thread *t);
22         void wake(Thread *t);
23         Thread * next_thread(Thread *t);
24         Thread * get_current_thread() const;
25         void print() const;
26
27         SNAPSHOTALLOC
28 private:
29         /** The list of available Threads that are not currently running */
30         std::list<Thread *> readyList;
31
32         /** The currently-running Thread */
33         Thread *current;
34 };
35
36 #endif /* __SCHEDULE_H__ */