activemq-cpp-3.9.5
MemoryUsage.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 _ACTIVEMQ_UTIL_MEMORYUSAGE_H_
19#define _ACTIVEMQ_UTIL_MEMORYUSAGE_H_
20
22#include <activemq/util/Usage.h>
24
25namespace activemq {
26namespace util {
27
28 class AMQCPP_API MemoryUsage : public Usage {
29 private:
30
31 // The physical limit of memory usage this object allows.
32 unsigned long long limit;
33
34 // Amount of memory currently used in.
35 unsigned long long usage;
36
37 // Mutex to lock usage and wait on.
39
40 public:
41
46
51 MemoryUsage(unsigned long long limit);
52
53 virtual ~MemoryUsage();
54
58 virtual void waitForSpace();
59
65 virtual void waitForSpace(unsigned int timeout);
66
72 virtual void enqueueUsage(unsigned long long value) {
74 increaseUsage(value);
75 }
76
81 virtual void increaseUsage(unsigned long long value);
82
87 virtual void decreaseUsage(unsigned long long value);
88
92 virtual bool isFull() const;
93
98 unsigned long long getUsage() const {
99 return usage;
100 }
101
106 void setUsage(unsigned long long usage) {
107 this->usage = usage;
108 }
109
114 unsigned long long getLimit() const {
115 return limit;
116 }
117
122 void setLimit(unsigned long long limit) {
123 this->limit = limit;
124 }
125
126 };
127
128}}
129
130#endif /*_ACTIVEMQ_UTIL_MEMORYUSAGE_H_*/
#define AMQCPP_API
Definition Config.h:30
virtual void enqueueUsage(unsigned long long value)
Tries to increase the usage by value amount but blocks if this object is currently full.
Definition MemoryUsage.h:72
unsigned long long getUsage() const
Gets the current usage amount.
Definition MemoryUsage.h:98
virtual bool isFull() const
Returns true if this Usage instance is full, i.e.
virtual void waitForSpace(unsigned int timeout)
Waits for more space to be returned to this Usage Manager, times out when the given time span in mill...
virtual void decreaseUsage(unsigned long long value)
Decreases the usage by the value amount.
MemoryUsage()
Default Constructor.
virtual void increaseUsage(unsigned long long value)
Increases the usage by the value amount.
unsigned long long getLimit() const
Gets the current limit amount.
Definition MemoryUsage.h:114
MemoryUsage(unsigned long long limit)
Creates an instance of an Usage monitor with a set limit.
void setUsage(unsigned long long usage)
Sets the current usage amount.
Definition MemoryUsage.h:106
void setLimit(unsigned long long limit)
Sets the current limit amount.
Definition MemoryUsage.h:122
virtual void waitForSpace()
Waits forever for more space to be returned to this Usage Manager.
Definition Usage.h:26
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition Mutex.h:39
Definition ActiveMQMessageTransformation.h:36
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24