00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "reac_thread.h"
00010
00011 static bool the_end = false;
00012
00013 static std :: vector <ReactiveThread *> reac_threads;
00014
00015 ReactiveThread :: ReactiveThread () {
00016
00017 reac_threads.push_back (this);
00018 sem_init (& sem, 0, 0);
00019 }
00020
00021 void ReactiveThread :: sleep () {
00022
00023 sem_wait (& sem);
00024 }
00025
00026 void ReactiveThread :: wakeUp () {
00027
00028 sem_post (& sem);
00029 }
00030
00031 void stopReactiveThreads () {
00032
00033 the_end = true;
00034 for (unsigned i = 0; i < reac_threads.size (); i ++)
00035 reac_threads [i] -> wakeUp ();
00036 }