D++ (DPP)
C++ Discord API Bot Library
|
The request_queue class manages rate limits and marshalls HTTP requests that have been built as http_request objects. More...
#include <queues.h>
Public Member Functions | |
request_queue (class cluster *owner) | |
~request_queue () | |
Destroy the request queue object. Side effects: Joins and deletes queue threads. More... | |
void | post_request (http_request *req) |
Put a http_request into the request queue. You should ALWAYS "new" an object to pass to here – don't submit an object that's on the stack! More... | |
The request_queue class manages rate limits and marshalls HTTP requests that have been built as http_request objects.
It ensures asynchronous delivery of events and queueing of requests.
It will spawn two threads, one to make outbound HTTP requests and push the returned results into a queue, and the second to call the callback methods with these results. They are separated so that if the user decides to take a long time processing a reply in their callback it won't affect when other requests are sent, and if a HTTP request takes a long time due to latency, it won't hold up user processing.
There are usually two request_queue objects in each dpp::cluster, one of which is used internally for the various REST methods to Discord such as sending messages, and the other used to support user REST calls via dpp::cluster::request().
dpp::request_queue::request_queue | ( | class cluster * | owner | ) |
Constructor
owner | The creating cluster. Side effects: Creates two threads for the queue |
dpp::request_queue::~request_queue | ( | ) |
Destroy the request queue object. Side effects: Joins and deletes queue threads.
void dpp::request_queue::post_request | ( | http_request * | req | ) |
Put a http_request into the request queue. You should ALWAYS "new" an object to pass to here – don't submit an object that's on the stack!
req | request to add |