Ocean
Loading...
Searching...
No Matches
NetworkResource.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef FACEBOOK_NETWORK_NETWORK_RESOURCE_H
9#define FACEBOOK_NETWORK_NETWORK_RESOURCE_H
10
12
13#include "ocean/base/Lock.h"
15
16namespace Ocean
17{
18
19namespace Network
20{
21
22/**
23 * This class implements a network resource manager object for platforms that rely on specific network/socket resource management.
24 * @ingroup network
25 */
26class OCEAN_NETWORK_EXPORT NetworkResource
27{
28 protected:
29
30 /**
31 * The manager of the parent resource object.
32 */
33 class Manager : public Singleton<Manager>
34 {
35 friend class Singleton<Manager>;
36
37 public:
38
39 /**
40 * Increases the resource.
41 * @return True, if the source is use for the first time
42 */
43 bool increase();
44
45 /**
46 * Decreases the resource.
47 * @return True, if the resource is not used anymore
48 */
49 bool decrease();
50
51 protected:
52
53 /**
54 * Creates a new manager.
55 */
57
58 protected:
59
60 /// The resource counter.
61 unsigned int resourceCounter_ = 0u;
62
63 /// The lock of the manager.
65 };
66
67 public:
68
69 /**
70 * Creates a new resource management object.
71 */
73
74 /**
75 * Destructs an resource management object.
76 */
78};
79
80}
81
82}
83
84#endif // FACEBOOK_NETWORK_NETWORK_RESOURCE_H
This class implements a recursive lock object.
Definition Lock.h:31
The manager of the parent resource object.
Definition NetworkResource.h:34
Lock lock_
The lock of the manager.
Definition NetworkResource.h:64
bool increase()
Increases the resource.
bool decrease()
Decreases the resource.
This class implements a network resource manager object for platforms that rely on specific network/s...
Definition NetworkResource.h:27
NetworkResource()
Creates a new resource management object.
This template class is the base class for all singleton objects.
Definition Singleton.h:71
The namespace covering the entire Ocean framework.
Definition Accessor.h:15