| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
dpp::request_concurrency_queue Class Reference

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>`

Collaboration diagram for dpp::request_concurrency_queue:
[legend]

## Public Member Functions

| request_concurrency_queue (class cluster *owner, class request_queue *req_q, uint32_t index)
| Construct a new concurrency queue object.
| ~request_concurrency_queue ()
| Destroy the concurrency queue object This will stop the timer.
void | post_request (std::unique_ptr< http_request > req)
| Post a http_request to this queue.
void | terminate ()
| Flags the queue as terminating This will set the internal atomic bool that indicates this queue is to accept no more requests.
void | tick_and_deliver_requests (uint32_t index)
| Timer callback.

## Public Attributes

std::map< std::string, bucket_t > | buckets
| Rate-limit bucket counters.
class cluster * | creator
| The cluster that owns this request_concurrency_queue.
int | in_index {0}
| Queue index.
std::shared_mutex | in_mutex
| Inbound queue mutex thread safety.
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.
std::mutex | rem_mutex
| Removals queue mutex thread safety.
std::vector< std::unique_ptr< http_request > > | removals
| Requests to remove after a set amount of time has passed.
class request_queue * | requests
| Request queue that owns this request_concurrency_queue.
std::vector< std::unique_ptr< http_request > > | requests_in
| Queue of requests to be made. Sorted by http_request::endpoint.
std::atomic< bool > | terminating
| True if ending.

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ request_concurrency_queue()

dpp::request_concurrency_queue::request_concurrency_queue | ( | class cluster * | owner,
|  | class request_queue * | req_q,
|  | uint32_t | index )

Construct a new concurrency queue object.

Parameters

  owner | Owning cluster
  req_q | Owning request queue
  index | Queue index number, uniquely identifies this queue for hashing

## ◆ ~request_concurrency_queue()

dpp::request_concurrency_queue::~request_concurrency_queue | ( |  | ) |

Destroy the concurrency queue object This will stop the timer.

## Member Function Documentation

## ◆ post_request()

void dpp::request_concurrency_queue::post_request | ( | std::unique_ptr< http_request > | req | ) |

Post a http_request to this queue.

Parameters

  req | http_request to post. The pointer will be freed when it has been executed.

## ◆ terminate()

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.

## ◆ tick_and_deliver_requests()

void dpp::request_concurrency_queue::tick_and_deliver_requests | ( | uint32_t | index | ) |

Timer callback.

Parameters

  index | Index ID for this timer

## Member Data Documentation

## ◆ buckets

std::map<std::string, bucket_t> dpp::request_concurrency_queue::buckets

Rate-limit bucket counters.

## ◆ creator

class cluster* dpp::request_concurrency_queue::creator

The cluster that owns this request_concurrency_queue.

## ◆ in_index

int dpp::request_concurrency_queue::in_index {0}

Queue index.

## ◆ in_mutex

std::shared_mutex dpp::request_concurrency_queue::in_mutex

Inbound queue mutex thread safety.

## ◆ in_timer

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.

## ◆ rem_mutex

std::mutex dpp::request_concurrency_queue::rem_mutex

Removals queue mutex thread safety.

## ◆ removals

std::vector<std::unique_ptr<http_request> > dpp::request_concurrency_queue::removals

Requests to remove after a set amount of time has passed.

## ◆ requests

class request_queue* dpp::request_concurrency_queue::requests

Request queue that owns this request_concurrency_queue.

## ◆ requests_in

std::vector<std::unique_ptr<http_request> > dpp::request_concurrency_queue::requests_in

Queue of requests to be made. Sorted by http_request::endpoint.

## ◆ terminating

std::atomic<bool> dpp::request_concurrency_queue::terminating

True if ending.

D++ Library version 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0