Electroneum
Loading...
Searching...
No Matches
network_throttle.cpp
Go to the documentation of this file.
1
28
29// Copyrights(c) 2017-2021, The Electroneum Project
30// Copyrights(c) 2014-2019, The Monero Project
31//
32// All rights reserved.
33//
34// Redistribution and use in source and binary forms, with or without modification, are
35// permitted provided that the following conditions are met:
36//
37// 1. Redistributions of source code must retain the above copyright notice, this list of
38// conditions and the following disclaimer.
39//
40// 2. Redistributions in binary form must reproduce the above copyright notice, this list
41// of conditions and the following disclaimer in the documentation and/or other
42// materials provided with the distribution.
43//
44// 3. Neither the name of the copyright holder nor the names of its contributors may be
45// used to endorse or promote products derived from this software without specific
46// prior written permission.
47//
48// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
49// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
50// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
51// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
53// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
56// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57
59
60namespace epee
61{
62namespace net_utils
63{
64
65// ================================================================================================
66// network_throttle_manager
67// ================================================================================================
68
69// ================================================================================================
70// static:
74
75// ================================================================================================
76// methods:
78 static network_throttle obj_get_global_throttle_in("in/all","<<< global-IN",10);
79 return obj_get_global_throttle_in;
80}
81
82
83
85 static network_throttle obj_get_global_throttle_inreq("inreq/all", "<== global-IN-REQ",10);
86 return obj_get_global_throttle_inreq;
87}
88
89
91 static network_throttle obj_get_global_throttle_out("out/all", ">>> global-OUT",10);
92 return obj_get_global_throttle_out;
93}
94
95
96
97
99 : m_in("in/"+name1, name1+"-DOWNLOAD"), m_inreq("inreq/"+name1, name1+"-DOWNLOAD-REQUESTS"), m_out("out/"+name1, name1+"-UPLOAD")
100{ }
101
102
103
104
105} // namespace
106} // namespace
107
108
109
110
111
static i_network_throttle & get_global_throttle_inreq()
ditto ; use lock ... use m_lock_get_global_throttle_inreq obviously
static i_network_throttle & get_global_throttle_in()
singleton ; for friend class ; caller MUST use proper locks! like m_lock_get_global_throttle_in
static i_network_throttle & get_global_throttle_out()
ditto ; use lock ... use m_lock_get_global_throttle_out obviously
implementaion for throttling of connection (count and rate-limit speed etc)
network_throttle m_in
for incomming traffic (this we can not controll directly as it depends of what others send to us - us...
network_throttle m_out
for outgoing traffic that we just sent (this is exact usually)
network_throttle_bw(const std::string &name1)
network_throttle m_inreq
for requesting incomming traffic (this is exact usually)