OOStuBS - Technische Informatik II (TI-II)  2.4
thread.cc
gehe zur Dokumentation dieser Datei
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2  * Technische Informatik II *
3  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * *
5  * T H R E A D *
6  * *
7 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8 
9 /* * * * * * * * * * * * * * * * * * * * * * * * *\
10 # INCLUDES #
11 \* * * * * * * * * * * * * * * * * * * * * * * * */
12 
13 #include "thread/thread.h"
14 #include "object/lock.h"
15 #include "object/scheduler.h"
16 #include "object/log.h"
17 
18 /* * * * * * * * * * * * * * * * * * * * * * * * *\
19 # METHODS #
20 \* * * * * * * * * * * * * * * * * * * * * * * * */
21 
22 void Thread::kickoff(Thread* thread){
23  log << "Thread " << thread << " starts execution" << endl;
24  lock.unlock();
25  thread->action();
26  while(true)
27  thread->exit();
28 }
29 
30 Thread::Thread() : context(this){}
31 
33  exit();
34 }
35 
37  scheduler.yield();
38 }
39 
40 void Thread::exit(){
41  scheduler.exit();
42 }