activemq-cpp-3.8.2
TimerTaskHeap.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_INTERNAL_UTIL_TIMERTASKHEAP_H_
19 #define _DECAF_INTERNAL_UTIL_TIMERTASKHEAP_H_
20 
21 #include <decaf/util/Config.h>
22 
23 #include <decaf/util/TimerTask.h>
24 #include <decaf/lang/Pointer.h>
25 
26 namespace decaf {
27 namespace internal {
28 namespace util {
29 
32 
39  private:
40 
41  // The default size of the Heap at creation.
42  static const int DEFAULT_HEAP_SIZE = 256;
43 
44  // Dynamic Array of TimerTasks used to represent the heap
45  std::vector<Pointer<TimerTask> > heap;
46 
47  public:
48 
49  TimerTaskHeap();
50  virtual ~TimerTaskHeap();
51 
58  Pointer<TimerTask> peek();
59 
63  bool isEmpty() const;
64 
68  std::size_t size() const;
69 
77  void insert(const Pointer<TimerTask>& task);
78 
86  void remove(std::size_t pos);
87 
91  void reset();
92 
96  void adjustMinimum();
97 
105  std::size_t deleteIfCancelled();
106 
113  std::size_t find(const Pointer<TimerTask>& task) const;
114 
115  private:
116 
117  void upHeap();
118  void downHeap(std::size_t pos);
119 
120  };
121 
122 }}}
123 
124 #endif /* _DECAF_INTERNAL_UTIL_TIMERTASKHEAP_H_ */
#define DECAF_API
Definition: Config.h:29
A Base class for a task object that can be scheduled for one-time or repeated execution by a Timer...
Definition: TimerTask.h:42
Decaf&#39;s implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
A Binary Heap implemented specifically for the Timer class in Decaf Util.
Definition: TimerTaskHeap.h:38