activemq-cpp-3.9.5
Timer.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _DECAF_UTIL_TIMER_H_
19#define _DECAF_UTIL_TIMER_H_
20
21#include <memory>
22
23#include <decaf/util/Config.h>
24#include <decaf/util/Date.h>
26#include <decaf/lang/Pointer.h>
30
31namespace decaf {
32namespace util {
33
34 class TimerTask;
35 class TimerImpl;
36
56 class DECAF_API Timer {
57 private:
58
59 TimerImpl* internal;
60
61 private:
62
63 Timer(const Timer&);
64 Timer operator=(const Timer&);
65
66 public:
67
69
76 Timer(const std::string& name);
77
78 virtual ~Timer();
79
91 void cancel();
92
108 bool awaitTermination(long long timeout, const decaf::util::concurrent::TimeUnit& unit);
109
125 int purge();
126
144 void schedule(TimerTask* task, long long delay);
145
156 void schedule(const decaf::lang::Pointer<TimerTask>& task, long long delay);
157
177 void schedule(TimerTask* task, const Date& time);
178
191 void schedule(const decaf::lang::Pointer<TimerTask>& task, const Date& time);
192
225 void schedule(TimerTask* task, long long delay, long long period);
226
252 void schedule(const decaf::lang::Pointer<TimerTask>& task, long long delay, long long period);
253
286 void schedule(TimerTask* task, const Date& firstTime, long long period);
287
313 void schedule(const decaf::lang::Pointer<TimerTask>& task, const Date& firstTime, long long period);
314
348 void scheduleAtFixedRate(TimerTask* task, long long delay, long long period);
349
376 void scheduleAtFixedRate(const decaf::lang::Pointer<TimerTask>& task, long long delay, long long period);
377
411 void scheduleAtFixedRate(TimerTask* task, const Date& firstTime, long long period);
412
439 void scheduleAtFixedRate(const decaf::lang::Pointer<TimerTask>& task, const Date& firstTime, long long period);
440
441 private:
442
443 void scheduleTask(const decaf::lang::Pointer<TimerTask>& task, long long delay, long long period, bool fixed);
444
445 };
446
447}}
448
449#endif /* _DECAF_UTIL_TIMER_H_ */
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
Wrapper class around a time value in milliseconds.
Definition Date.h:34
void schedule(TimerTask *task, long long delay, long long period)
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
Timer(const std::string &name)
Create a new Timer whose associated thread is assigned the name given.
void schedule(const decaf::lang::Pointer< TimerTask > &task, long long delay)
Schedules the specified task for execution after the specified delay.
void schedule(const decaf::lang::Pointer< TimerTask > &task, const Date &time)
Schedules the specified task for execution at the specified time.
void scheduleAtFixedRate(const decaf::lang::Pointer< TimerTask > &task, const Date &firstTime, long long period)
Schedules the specified task for repeated fixed-rate execution, beginning at the specified time.
bool awaitTermination(long long timeout, const decaf::util::concurrent::TimeUnit &unit)
The caller will block until the Timer has completed termination meaning all tasks that where schedule...
void scheduleAtFixedRate(TimerTask *task, const Date &firstTime, long long period)
Schedules the specified task for repeated fixed-rate execution, beginning at the specified time.
void cancel()
Terminates this timer, discarding any currently scheduled tasks.
void schedule(const decaf::lang::Pointer< TimerTask > &task, const Date &firstTime, long long period)
Schedules the specified task for repeated fixed-delay execution, beginning at the specified time.
void scheduleAtFixedRate(TimerTask *task, long long delay, long long period)
Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
void schedule(TimerTask *task, const Date &firstTime, long long period)
Schedules the specified task for repeated fixed-delay execution, beginning at the specified time.
void scheduleAtFixedRate(const decaf::lang::Pointer< TimerTask > &task, long long delay, long long period)
Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
void schedule(const decaf::lang::Pointer< TimerTask > &task, long long delay, long long period)
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
int purge()
Removes all canceled tasks from this timer's task queue.
void schedule(TimerTask *task, long long delay)
Schedules the specified task for execution after the specified delay.
void schedule(TimerTask *task, const Date &time)
Schedules the specified task for execution at the specified time.
A Base class for a task object that can be scheduled for one-time or repeated execution by a Timer.
Definition TimerTask.h:42
A TimeUnit represents time durations at a given unit of granularity and provides utility methods to c...
Definition TimeUnit.h:62
#define DECAF_API
Definition Config.h:29
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25