00001 /* hasTimer.h 00002 */ 00003 #ifndef _HASTIMER_H 00004 #define _HASTIMER_H 00005 #include "osl/misc/realTime.h" 00006 #include "osl/misc/lightMutex.h" 00007 namespace osl 00008 { 00009 namespace search 00010 { 00011 class HasTimer 00012 { 00014 misc::RealTime stop_schedule; 00015 typedef LightMutex Mutex; 00016 mutable Mutex mutex; 00018 volatile double next_iteration_coefficient; 00019 public: 00020 HasTimer() : stop_schedule(-1), next_iteration_coefficient(4.0) { 00021 } 00022 HasTimer(const HasTimer& src) : stop_schedule(src.stopSchedule()) { 00023 } 00024 virtual ~HasTimer(); 00025 void setStopSchedule(const misc::RealTime& schedule) { 00026 Mutex::scoped_lock lk(mutex); 00027 stop_schedule = schedule; 00028 } 00029 bool hasSchedule() const { 00030 Mutex::scoped_lock lk(mutex); 00031 return ! stop_schedule.isInvalid(); 00032 } 00033 const misc::RealTime stopSchedule() const { 00034 Mutex::scoped_lock lk(mutex); 00035 return stop_schedule; 00036 } 00037 void setNextIterationCoefficient(double new_value) { 00038 Mutex::scoped_lock lk(mutex); 00039 next_iteration_coefficient = new_value; 00040 } 00041 double nextIterationCoefficient() const { 00042 Mutex::scoped_lock lk(mutex); 00043 return next_iteration_coefficient; 00044 } 00045 }; 00046 } // namespace search 00047 } // namespace osl 00048 00049 00050 #endif /* _HASTIMER_H */ 00051 // ;;; Local Variables: 00052 // ;;; mode:c++ 00053 // ;;; c-basic-offset:2 00054 // ;;; End: