Flow-IPC 1.0.0
Flow-IPC project: Full implementation reference.
use_counted_object.hpp
Go to the documentation of this file.
1/* Flow-IPC: Core
2 * Copyright 2023 Akamai Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the
5 * "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14 * CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License. */
17
18/// @file
19#pragma once
20
21#include <cassert>
22
23namespace ipc::util
24{
25
26/// Simple counter that manually tracks utilization. It is not thread-safe.
28{
29public:
30
31 // Constructors/destructor.
32
33 /// Constructor.
35
36 // Methods.
37
38 /**
39 * Returns the current usage.
40 * @return See above.
41 */
42 unsigned int get_use_count() const;
43
44 /// Increments the usage.
45 void increment_use();
46
47 /// Decrements the usage. The current count must be greater than one.
48 void decrement_use();
49
50private:
51 // Data.
52
53 /// The current usage count.
54 unsigned int m_use_count;
55}; // class Use_counted_object
56
57} // namespace ipc::util
Simple counter that manually tracks utilization. It is not thread-safe.
void decrement_use()
Decrements the usage. The current count must be greater than one.
void increment_use()
Increments the usage.
unsigned int get_use_count() const
Returns the current usage.
unsigned int m_use_count
The current usage count.
Flow-IPC module containing miscellaneous general-use facilities that ubiquitously used by ~all Flow-I...