tprocess.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _tprocess_h
00030 #define _tprocess_h
00031
00032 #ifndef TPROCESS_IMPL
00033 #include "tprocessconf.h"
00034 #endif
00035
00036 #if TPROCESS_IMPL != 0
00037
00038 #if TPROCESS_IMPL==1
00039 #include <ucontext.h>
00040 #else
00041 #include <setjmp.h>
00042 #endif
00043
00044 #include <siena/ssim.h>
00045
00051 namespace ssim {
00052
00068 class TProcess : public Process {
00069 public:
00074 TProcess();
00075
00077 TProcess(unsigned long stacksize);
00078
00079 virtual ~TProcess();
00080
00090 virtual void main() = 0;
00091
00097 static unsigned long DefaultStackSize;
00098
00104 class Timeout : public Event { };
00105
00148 static const Event * wait_for_event(Time timeout = INIT_TIME);
00149
00150 private:
00151 virtual void init(void);
00152 virtual void process_event(const Event * msg);
00153 virtual void stop(void);
00154
00155 #if TPROCESS_IMPL==1
00156 ucontext_t running_ctx;
00157 #else
00158 jmp_buf running_ctx;
00159 #endif
00160 char * mystack;
00161 unsigned long mystack_size;
00162
00163 const Event * ev;
00164
00165 #if TPROCESS_IMPL==1
00166 static void starter();
00167 #else
00168 static void starter(int);
00169 #endif
00170 void pause();
00171 void resume();
00172 };
00173
00174 };
00175
00176 #endif
00177
00178 #endif
00179