00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTIL_TIMER_H_
00019 #define _DECAF_UTIL_TIMER_H_
00020
00021 #include <memory>
00022
00023 #include <decaf/util/Config.h>
00024 #include <decaf/util/Date.h>
00025 #include <decaf/util/concurrent/TimeUnit.h>
00026 #include <decaf/lang/Pointer.h>
00027 #include <decaf/lang/exceptions/NullPointerException.h>
00028 #include <decaf/lang/exceptions/IllegalStateException.h>
00029 #include <decaf/lang/exceptions/IllegalArgumentException.h>
00030
00031 namespace decaf {
00032 namespace util {
00033
00034 class TimerTask;
00035 class TimerImpl;
00036
00056 class DECAF_API Timer {
00057 private:
00058
00059 TimerImpl* internal;
00060
00061 private:
00062
00063 Timer(const Timer&);
00064 Timer operator=(const Timer&);
00065
00066 public:
00067
00068 Timer();
00069
00076 Timer(const std::string& name);
00077
00078 virtual ~Timer();
00079
00091 void cancel();
00092
00108 bool awaitTermination(long long timeout, const decaf::util::concurrent::TimeUnit& unit);
00109
00125 int purge();
00126
00144 void schedule(TimerTask* task, long long delay);
00145
00156 void schedule(const decaf::lang::Pointer<TimerTask>& task, long long delay);
00157
00177 void schedule(TimerTask* task, const Date& time);
00178
00191 void schedule(const decaf::lang::Pointer<TimerTask>& task, const Date& time);
00192
00225 void schedule(TimerTask* task, long long delay, long long period);
00226
00252 void schedule(const decaf::lang::Pointer<TimerTask>& task, long long delay, long long period);
00253
00286 void schedule(TimerTask* task, const Date& firstTime, long long period);
00287
00313 void schedule(const decaf::lang::Pointer<TimerTask>& task, const Date& firstTime, long long period);
00314
00348 void scheduleAtFixedRate(TimerTask* task, long long delay, long long period);
00349
00376 void scheduleAtFixedRate(const decaf::lang::Pointer<TimerTask>& task, long long delay, long long period);
00377
00411 void scheduleAtFixedRate(TimerTask* task, const Date& firstTime, long long period);
00412
00439 void scheduleAtFixedRate(const decaf::lang::Pointer<TimerTask>& task, const Date& firstTime, long long period);
00440
00441 private:
00442
00443 void scheduleTask(const decaf::lang::Pointer<TimerTask>& task, long long delay, long long period, bool fixed);
00444
00445 };
00446
00447 }}
00448
00449 #endif