D++ (DPP)
C++ Discord API Bot Library
|
Represents a timer instance in a pool handling requests to HTTP(S) servers. There are several of these, the total defined by a constant in cluster.cpp, and each one will always receive requests for the same rate limit bucket based on its endpoint portion of the url. This makes rate limit handling reliable and easy to manage. Each of these also has its own mutex, making it thread safe to call and use these from anywhere in the code. More...
#include <queues.h>
Public Member Functions | |
void | tick_and_deliver_requests (uint32_t index) |
Timer callback. More... | |
request_concurrency_queue (class cluster *owner, class request_queue *req_q, uint32_t index) | |
Construct a new concurrency queue object. More... | |
~request_concurrency_queue () | |
Destroy the concurrency queue object This will stop the timer. More... | |
void | terminate () |
Flags the queue as terminating This will set the internal atomic bool that indicates this queue is to accept no more requests. More... | |
void | post_request (std::unique_ptr< http_request > req) |
Post a http_request to this queue. More... | |
Public Attributes | |
int | in_index {0} |
Queue index. More... | |
std::atomic< bool > | terminating |
True if ending. More... | |
class request_queue * | requests |
Request queue that owns this request_concurrency_queue. More... | |
class cluster * | creator |
The cluster that owns this request_concurrency_queue. More... | |
std::shared_mutex | in_mutex |
Inbound queue mutex thread safety. More... | |
dpp::timer | in_timer |
Inbound queue timer. The timer is called every second, and when it wakes up it checks for requests pending to be sent in the queue. If there are any requests and we are not waiting on rate limit, it will send them, else it will wait for the rate limit to expire. More... | |
std::map< std::string, bucket_t > | buckets |
Rate-limit bucket counters. More... | |
std::vector< std::unique_ptr< http_request > > | requests_in |
Queue of requests to be made. Sorted by http_request::endpoint. More... | |
std::vector< std::unique_ptr< http_request > > | removals |
Requests to remove after a set amount of time has passed. More... | |
Represents a timer instance in a pool handling requests to HTTP(S) servers. There are several of these, the total defined by a constant in cluster.cpp, and each one will always receive requests for the same rate limit bucket based on its endpoint portion of the url. This makes rate limit handling reliable and easy to manage. Each of these also has its own mutex, making it thread safe to call and use these from anywhere in the code.
dpp::request_concurrency_queue::request_concurrency_queue | ( | class cluster * | owner, |
class request_queue * | req_q, | ||
uint32_t | index | ||
) |
Construct a new concurrency queue object.
owner | Owning cluster |
req_q | Owning request queue |
index | Queue index number, uniquely identifies this queue for hashing |
dpp::request_concurrency_queue::~request_concurrency_queue | ( | ) |
Destroy the concurrency queue object This will stop the timer.
void dpp::request_concurrency_queue::post_request | ( | std::unique_ptr< http_request > | req | ) |
Post a http_request to this queue.
req | http_request to post. The pointer will be freed when it has been executed. |
void dpp::request_concurrency_queue::terminate | ( | ) |
Flags the queue as terminating This will set the internal atomic bool that indicates this queue is to accept no more requests.
void dpp::request_concurrency_queue::tick_and_deliver_requests | ( | uint32_t | index | ) |
Timer callback.
index | Index ID for this timer |
std::map<std::string, bucket_t> dpp::request_concurrency_queue::buckets |
Rate-limit bucket counters.
class cluster* dpp::request_concurrency_queue::creator |
The cluster that owns this request_concurrency_queue.
int dpp::request_concurrency_queue::in_index {0} |
Queue index.
std::shared_mutex dpp::request_concurrency_queue::in_mutex |
Inbound queue mutex thread safety.
dpp::timer dpp::request_concurrency_queue::in_timer |
Inbound queue timer. The timer is called every second, and when it wakes up it checks for requests pending to be sent in the queue. If there are any requests and we are not waiting on rate limit, it will send them, else it will wait for the rate limit to expire.
std::vector<std::unique_ptr<http_request> > dpp::request_concurrency_queue::removals |
Requests to remove after a set amount of time has passed.
class request_queue* dpp::request_concurrency_queue::requests |
Request queue that owns this request_concurrency_queue.
std::vector<std::unique_ptr<http_request> > dpp::request_concurrency_queue::requests_in |
Queue of requests to be made. Sorted by http_request::endpoint.
std::atomic<bool> dpp::request_concurrency_queue::terminating |
True if ending.