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 #ifndef INFINITELOOP_H
00028 #define INFINITELOOP_H
00029
00030 #include "GpCoreToolsDLLExport.h"
00031
00032 namespace GpCoreTools {
00033
00034 class GPCORETOOLS_EXPORT InfiniteLoop
00035 {
00036 public:
00037 InfiniteLoop();
00038 ~InfiniteLoop();
00039
00040 inline void start();
00041 inline void stop();
00042 void wait();
00043 inline bool isRunning() const;
00044 protected:
00045 inline bool isTerminated() const;
00046 inline void setTerminated();
00047 private:
00048 enum State {NotRunning, Running, Terminate};
00049 volatile State _state;
00050 };
00051
00052 inline void InfiniteLoop::start()
00053 {
00054 _state=Running;
00055 }
00056
00057 inline void InfiniteLoop::stop()
00058 {
00059 if(_state==Running) {
00060 _state=Terminate;
00061 }
00062 }
00063
00064 inline bool InfiniteLoop::isRunning() const
00065 {
00066 return _state!=NotRunning;
00067 }
00068
00069 inline bool InfiniteLoop::isTerminated() const
00070 {
00071 return _state==Terminate;
00072 }
00073
00074 inline void InfiniteLoop::setTerminated()
00075 {
00076 _state=NotRunning;
00077 }
00078
00079 }
00080
00081 #endif // INFINITELOOP_H