activemq-cpp-3.3.0

src/main/decaf/util/TimerTask.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _DECAF_UTIL_TIMERTASK_H_
00019 #define _DECAF_UTIL_TIMERTASK_H_
00020 
00021 #include <decaf/util/Config.h>
00022 #include <decaf/lang/Runnable.h>
00023 #include <decaf/util/concurrent/Mutex.h>
00024 
00025 namespace decaf {
00026 namespace internal{
00027     namespace util{
00028         class TimerTaskHeap;
00029     }
00030 }
00031 namespace util {
00032 
00033     class Timer;
00034     class TimerImpl;
00035 
00042     class DECAF_API TimerTask : public lang::Runnable {
00043     private:
00044 
00045         // Timer will use this lock to sync with mutating methods in this class.
00046         mutable decaf::util::concurrent::Mutex lock;
00047 
00048         bool fixedRate;
00049         bool cancelled;
00050         long long scheduledTime;
00051         long long when;
00052         long long period;
00053 
00054         friend class Timer;
00055         friend class TimerImpl;
00056         friend class decaf::internal::util::TimerTaskHeap;
00057 
00058     public:
00059 
00060         TimerTask();
00061         virtual ~TimerTask() {}
00062 
00080         bool cancel();
00081 
00104         long long scheduledExecutionTime() const;
00105 
00106     protected:
00107 
00108         bool isScheduled() const;
00109         void setScheduledTime( long long time );
00110         long long getWhen() const;
00111 
00112     };
00113 
00114 }}
00115 
00116 #endif /* _DECAF_UTIL_TIMERTASK_H_ */