687d30612d2e2c3549caf4e922210885fad94941
[cdsspec-compiler.git] / schedule.cc
1 #include <stdlib.h>
2
3 #include "libthreads.h"
4 #include "schedule.h"
5 #include "common.h"
6 #include "model.h"
7
8 struct thread *current;
9
10 void DefaultScheduler::add_thread(struct thread *t)
11 {
12         DEBUG("thread %d\n", t->id);
13         queue.push_back(t);
14 }
15
16 struct thread *DefaultScheduler::next_thread(void)
17 {
18         struct thread *t;
19
20         if (queue.empty())
21                 return NULL;
22
23         t = queue.front();
24         queue.pop_front();
25
26         current = t;
27
28         return t;
29 }
30
31 struct thread *DefaultScheduler::get_current_thread(void)
32 {
33         return current;
34 }