activemq-cpp-3.9.5
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
24#include <decaf/lang/Pointer.h>
25
26namespace decaf {
27namespace internal {
28namespace util {
29
30 using decaf::lang::Pointer;
31 using decaf::util::TimerTask;
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
50 virtual ~TimerTaskHeap();
51
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
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_ */
void reset()
Clear all contents from the heap.
void insert(const Pointer< TimerTask > &task)
Inserts the specified Task into the heap, heap is reordered to reflect the addition of a new element.
void adjustMinimum()
Resorts the heap starting at the top.
void remove(std::size_t pos)
Removes the Task at the specified position from the heap, resorts the heap from the position down to ...
std::size_t find(const Pointer< TimerTask > &task) const
Searches the heap for the specified TimerTask element and returns its position in the heap.
std::size_t deleteIfCancelled()
Runs through the heap removing all cancelled Tasks from it, this is not normally used but in case a a...
Pointer< TimerTask > peek()
Peaks at the Head of the Heap, returns the task with the nearest scheduled run time.
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
#define DECAF_API
Definition Config.h:29
Definition ByteArrayAdapter.h:30
Definition AprPool.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25