Skip to content

Commit

Permalink
Merge pull request #3 from c4games/master
Browse files Browse the repository at this point in the history
Sync with master
  • Loading branch information
rh101 authored Apr 22, 2021
2 parents 2cef9f2 + 844119d commit 0886473
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 12 deletions.
22 changes: 12 additions & 10 deletions cocos/network/CCDownloader-curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions cocos/network/CCIDownloaderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ android {

externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android {

externalNativeBuild {
cmake {
version "3.10.0+"
path "../../../../CMakeLists.txt"
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/cpp-empty-test/proj.android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ android {

externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/proj.android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android {

externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/fairygui-tests/proj.android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ android {

externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/lua-empty-test/project/proj.android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android {

externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/lua-tests/project/proj.android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android {

externalNativeBuild {
cmake {
version "3.10.0+"
path "../../CMakeLists.txt"
}
}
Expand Down

0 comments on commit 0886473

Please sign in to comment.