|
OpenTTD Source 20251104-master-g3befbdd52f
|
Converts a HTTPCallback to a Thread-Safe variant. More...
#include <http_shared.h>
Data Structures | |
| class | Callback |
| Entries on the queue for later handling. More... | |
Public Member Functions | |
| void | OnFailure () |
| Similar to HTTPCallback::OnFailure, but thread-safe. | |
| void | OnReceiveData (std::unique_ptr< char[]> data, size_t length) |
| Similar to HTTPCallback::OnReceiveData, but thread-safe. | |
| void | HandleQueue () |
| Process everything on the queue. | |
| template<typename T > | |
| void | WaitTillEmptyOrCondition (T condition) |
| Wait till the queue is dequeued, or a condition is met. | |
| bool | IsQueueEmpty () |
| Check if the queue is empty. | |
| HTTPThreadSafeCallback (HTTPCallback *callback) | |
Data Fields | |
| std::atomic< bool > | cancelled = false |
Private Attributes | |
| HTTPCallback * | callback |
| The callback to send data back on. | |
| std::mutex | mutex |
| Mutex to protect the queue. | |
| std::vector< Callback > | queue |
| Queue of data to send back. | |
| std::condition_variable | queue_cv |
| Condition variable to wait for the queue to be empty. | |
Converts a HTTPCallback to a Thread-Safe variant.
Definition at line 22 of file http_shared.h.
|
inline |
Definition at line 100 of file http_shared.h.
|
inline |
Definition at line 102 of file http_shared.h.
|
inline |
Process everything on the queue.
Should be called from the Game Thread.
Definition at line 59 of file http_shared.h.
References callback, HTTPCallback::IsCancelled(), lock, mutex, HTTPCallback::OnFailure(), HTTPCallback::OnReceiveData(), queue, and queue_cv.
|
inline |
Check if the queue is empty.
Definition at line 94 of file http_shared.h.
References lock, mutex, and queue.
Referenced by NetworkHTTPRequest::Receive().
|
inline |
Similar to HTTPCallback::OnFailure, but thread-safe.
Definition at line 39 of file http_shared.h.
References lock, mutex, and queue.
Referenced by NetworkHTTPRequest::Connect(), NetworkHTTPRequest::Receive(), and NetworkHTTPRequest::WinHttpCallback().
|
inline |
Similar to HTTPCallback::OnReceiveData, but thread-safe.
Definition at line 48 of file http_shared.h.
References lock, mutex, and queue.
Referenced by NetworkHTTPRequest::WinHttpCallback().
|
inline |
|
private |
The callback to send data back on.
Definition at line 114 of file http_shared.h.
Referenced by HandleQueue().
| std::atomic<bool> HTTPThreadSafeCallback::cancelled = false |
Definition at line 111 of file http_shared.h.
|
private |
Mutex to protect the queue.
Definition at line 115 of file http_shared.h.
Referenced by HandleQueue(), IsQueueEmpty(), OnFailure(), OnReceiveData(), and WaitTillEmptyOrCondition().
|
private |
Queue of data to send back.
Definition at line 116 of file http_shared.h.
Referenced by HandleQueue(), IsQueueEmpty(), OnFailure(), OnReceiveData(), and WaitTillEmptyOrCondition().
|
private |
Condition variable to wait for the queue to be empty.
Definition at line 117 of file http_shared.h.
Referenced by HandleQueue(), and WaitTillEmptyOrCondition().