#include <nnratelimiter.h>
Inheritance diagram for NewNet::RateLimiter:

Public Member Functions | |
| RateLimiter () | |
| Constructor. | |
| ssize_t | limit () const |
| Get the current transfer rate limit. | |
| void | setLimit (ssize_t limit) |
| Set the transfer rate limit. | |
| void | transferred (ssize_t bytes) |
| Feed bytes to the collector. | |
| long | nextWindow () |
| Next window of opportunity. | |
Definition at line 31 of file nnratelimiter.h.
| NewNet::RateLimiter::RateLimiter | ( | ) |
Create a new rate limiter. The limit will be initialized to -1 which means that there will be no rate limiting.
Definition at line 40 of file nnratelimiter.cpp.
| ssize_t NewNet::RateLimiter::limit | ( | ) | const [inline] |
This returns the current transfer rate limit in bytes per second. 0 means that no traffic will be allowed to be sent. A value of -1 means that there is no limit set.
Definition at line 47 of file nnratelimiter.h.
| void NewNet::RateLimiter::setLimit | ( | ssize_t | limit | ) | [inline] |
This changes the current transfer rate limit. The limit is measured in bytes per second. A value of 0 means that no traffic will be allowed to pass. A value of -1 means that no limit is enforced.
Definition at line 56 of file nnratelimiter.h.
| void NewNet::RateLimiter::transferred | ( | ssize_t | bytes | ) |
This adds a frame of bytes to the rate limit collector. NewNet::ClientSocket calls this whenever it received or sent data of the socket.
Definition at line 54 of file nnratelimiter.cpp.
Referenced by NewNet::ClientSocket::process().
| long NewNet::RateLimiter::nextWindow | ( | ) |
This will predict when the rate limit will be 'unbreached' and when data will be allowed to be transferred again. If the limit is set to 0 this always returns 60000 (60 seconds). If the limit is set to -1, it always returns 0. Otherwise, it returns the number of miliseconds until the next opportunity.
Definition at line 80 of file nnratelimiter.cpp.
1.5.1