Merge pull request #3 from c4games/master

Sync with master
This commit is contained in:
RH 2021-04-22 21:48:49 +10:00 committed by GitHub
commit 0886473e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 12 deletions

View File

@ -367,11 +367,16 @@ namespace cocos2d { namespace network {
void run()
{
lock_guard<mutex> lock(_threadMutex);
if (!_thread.joinable())
{
std::thread newThread(&DownloaderCURL::Impl::_threadProc, this);
_thread.swap(newThread);
if (_tasksFinished)
{ // all tasks finished, make sure thread not joinable
if (_thread.joinable())
_thread.join();
_tasksFinished = false;
}
if (!_thread.joinable())
_thread = std::thread(&DownloaderCURL::Impl::_threadProc, this);
}
void stop()
@ -392,12 +397,6 @@ namespace cocos2d { namespace network {
_thread.join();
}
bool stoped()
{
lock_guard<mutex> lock(_threadMutex);
return !_thread.joinable();
}
void getProcessTasks(vector<TaskWrapper>& outList)
{
lock_guard<mutex> lock(_processMutex);
@ -808,11 +807,14 @@ namespace cocos2d { namespace network {
}
} while (!coTaskMap.empty());
_tasksFinished = true;
curl_multi_cleanup(curlmHandle);
DLLOG("----DownloaderCURL::Impl::_threadProc end");
}
thread _thread;
std::atomic_bool _tasksFinished{};
deque<TaskWrapper> _requestQueue;
set<TaskWrapper> _processSet;
// deque<TaskWrapper> _finishedQueue;

View File

@ -31,8 +31,8 @@ THE SOFTWARE.
#include "base/CCConsole.h"
//#define CC_DOWNLOADER_DEBUG
#ifdef CC_DOWNLOADER_DEBUG
// #define CC_DOWNLOADER_DEBUG
#if defined(CC_DOWNLOADER_DEBUG) || defined(_DEBUG)
#define DLLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
#else
#define DLLOG(...) do {} while (0)

View File

@ -34,6 +34,7 @@ android {
externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}

View File

@ -35,6 +35,7 @@ android {
externalNativeBuild {
cmake {
version "3.10.0+"
path "../../../../CMakeLists.txt"
}
}

View File

@ -36,6 +36,7 @@ android {
externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}

View File

@ -35,6 +35,7 @@ android {
externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}

View File

@ -36,6 +36,7 @@ android {
externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}

View File

@ -35,6 +35,7 @@ android {
externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}

View File

@ -35,6 +35,7 @@ android {
externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}