mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 00:26:56 +00:00
Improve performance of PC polling with many paired PCs
This commit is contained in:
parent
f485c8ce49
commit
94df20bbee
@ -80,7 +80,7 @@ int http_request(char* url, PHTTP_DATA data) {
|
||||
curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5L);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3L);
|
||||
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
|
8
main.cpp
8
main.cpp
@ -22,8 +22,6 @@
|
||||
|
||||
MoonlightInstance* g_Instance;
|
||||
|
||||
MoonlightInstance::~MoonlightInstance() {}
|
||||
|
||||
class MoonlightModule : public pp::Module {
|
||||
public:
|
||||
MoonlightModule() : pp::Module() {}
|
||||
@ -258,13 +256,15 @@ void MoonlightInstance::HandleOpenURL(int32_t callbackId, pp::VarArray args) {
|
||||
std::string url = args.Get(0).AsString();
|
||||
bool binaryResponse = args.Get(1).AsBool();
|
||||
|
||||
openHttpThread.message_loop().PostWork(m_CallbackFactory.NewCallback(&MoonlightInstance::NvHTTPRequest, callbackId, url, binaryResponse));
|
||||
m_HttpThreadPool[m_HttpThreadPoolSequence++ % HTTP_HANDLER_THREADS]->message_loop().PostWork(
|
||||
m_CallbackFactory.NewCallback(&MoonlightInstance::NvHTTPRequest, callbackId, url, binaryResponse));
|
||||
|
||||
PostMessage(pp::Var (url.c_str()));
|
||||
}
|
||||
|
||||
void MoonlightInstance::HandlePair(int32_t callbackId, pp::VarArray args) {
|
||||
openHttpThread.message_loop().PostWork(m_CallbackFactory.NewCallback(&MoonlightInstance::PairCallback, callbackId, args));
|
||||
m_HttpThreadPool[m_HttpThreadPoolSequence++ % HTTP_HANDLER_THREADS]->message_loop().PostWork(
|
||||
m_CallbackFactory.NewCallback(&MoonlightInstance::PairCallback, callbackId, args));
|
||||
}
|
||||
|
||||
void MoonlightInstance::PairCallback(int32_t /*result*/, int32_t callbackId, pp::VarArray args) {
|
||||
|
@ -38,6 +38,11 @@
|
||||
|
||||
#define DR_FLAG_FORCE_SW_DECODE 0x01
|
||||
|
||||
// These will mostly be I/O bound so we'll create
|
||||
// a bunch to allow more concurrent server requests
|
||||
// since our HTTP request libary is synchronous.
|
||||
#define HTTP_HANDLER_THREADS 8
|
||||
|
||||
struct Shader {
|
||||
Shader() : program(0), texcoord_scale_location(0) {}
|
||||
~Shader() {}
|
||||
@ -61,7 +66,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
m_AccumulatedTicks(0),
|
||||
m_MouseDeltaX(0),
|
||||
m_MouseDeltaY(0),
|
||||
openHttpThread(this) {
|
||||
m_HttpThreadPoolSequence(0) {
|
||||
// This function MUST be used otherwise sockets don't work (nacl_io_init() doesn't work!)
|
||||
nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface());
|
||||
|
||||
@ -71,10 +76,18 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
|
||||
m_GamepadApi = static_cast<const PPB_Gamepad*>(pp::Module::Get()->GetBrowserInterface(PPB_GAMEPAD_INTERFACE));
|
||||
|
||||
openHttpThread.Start();
|
||||
for (int i = 0; i < HTTP_HANDLER_THREADS; i++) {
|
||||
m_HttpThreadPool[i] = new pp::SimpleThread(this);
|
||||
m_HttpThreadPool[i]->Start();
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~MoonlightInstance();
|
||||
virtual ~MoonlightInstance() {
|
||||
for (int i = 0; i < HTTP_HANDLER_THREADS; i++) {
|
||||
m_HttpThreadPool[i]->Join();
|
||||
delete m_HttpThreadPool[i];
|
||||
}
|
||||
}
|
||||
|
||||
bool Init(uint32_t argc, const char* argn[], const char* argv[]);
|
||||
|
||||
@ -178,7 +191,8 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
float m_AccumulatedTicks;
|
||||
int32_t m_MouseDeltaX, m_MouseDeltaY;
|
||||
|
||||
pp::SimpleThread openHttpThread;
|
||||
pp::SimpleThread* m_HttpThreadPool[HTTP_HANDLER_THREADS];
|
||||
uint32_t m_HttpThreadPoolSequence;
|
||||
};
|
||||
|
||||
extern MoonlightInstance* g_Instance;
|
||||
|
@ -138,7 +138,7 @@ NvHTTP.prototype = {
|
||||
completion(this);
|
||||
}
|
||||
}.bind(this), function() {
|
||||
if (++this._consecutivePollFailures >= 3) {
|
||||
if (++this._consecutivePollFailures >= 2) {
|
||||
this.online = false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user