1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Add thread support to HTTPRequest, changed assetlib to use it.

This commit is contained in:
Juan Linietsky
2016-07-24 16:09:43 -03:00
parent 85f365bbff
commit ab93fd1af9
3 changed files with 102 additions and 26 deletions

View File

@@ -32,6 +32,7 @@
#include "node.h"
#include "io/http_client.h"
#include "os/file_access.h"
#include "os/thread.h"
class HTTPRequest : public Node {
@@ -69,7 +70,7 @@ private:
bool request_sent;
Ref<HTTPClient> client;
ByteArray body;
bool use_threads;
volatile bool use_threads;
bool got_response;
int response_code;
@@ -80,7 +81,7 @@ private:
FileAccess *file;
int body_len;
int downloaded;
volatile int downloaded;
int body_size_limit;
int redirections;
@@ -93,11 +94,19 @@ private:
void _redirect_request(const String& p_new_url);
bool _handle_response(bool *ret_value);
Error _parse_url(const String& p_url);
Error _request();
volatile bool thread_done;
volatile bool thread_request_quit;
Thread *thread;
void _request_done(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data);
static void _thread_func(void *p_userdata);
protected: