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 () | |
void | post_request (http_request *req) |
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 is usually only one request_queue object in each dpp::cluster, which is used internally for the various REST methods such as sending messages.
dpp::request_queue::request_queue | ( | class cluster * | owner | ) |
Constructor
owner | The creating cluster |
dpp::request_queue::~request_queue | ( | ) |
Destructor
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 |