diff --git a/core/base/CCDirector.cpp b/core/base/CCDirector.cpp index 52d30a0b24..2883a5f2b1 100644 --- a/core/base/CCDirector.cpp +++ b/core/base/CCDirector.cpp @@ -1461,7 +1461,7 @@ void Director::startAnimation(SetIntervalReason reason) _invalid = false; - _cocos2d_thread_id = std::this_thread::get_id(); + _axmol_thread_id = std::this_thread::get_id(); Application::getInstance()->setAnimationInterval(_animationInterval); diff --git a/core/base/CCDirector.h b/core/base/CCDirector.h index bf917e0198..3ac1a7ba05 100644 --- a/core/base/CCDirector.h +++ b/core/base/CCDirector.h @@ -488,10 +488,11 @@ public: void resetMatrixStack(); /** - * returns the cocos2d thread id. - Useful to know if certain code is already running on the cocos2d thread + * returns the axmol thread id. + Useful to know if certain code is already running on the axmol thread */ - const std::thread::id& getCocos2dThreadId() const { return _cocos2d_thread_id; } + const std::thread::id& getCocos2dThreadId() const { return getAxmolThreadId(); } + const std::thread::id& getAxmolThreadId() const { return _axmol_thread_id; } /** Enable node tree children indexer map, the concept is like database INDEX * Notes: @@ -644,8 +645,8 @@ protected: bool _childrenIndexerEnabled = false; - /* cocos2d thread id */ - std::thread::id _cocos2d_thread_id; + /* axmol thread id */ + std::thread::id _axmol_thread_id; // GLView will recreate stats labels to fit visible rect friend class GLView; diff --git a/core/network/HttpClient.cpp b/core/network/HttpClient.cpp index a7d4ab939c..7d63e2b8d3 100644 --- a/core/network/HttpClient.cpp +++ b/core/network/HttpClient.cpp @@ -465,7 +465,7 @@ void HttpClient::finishResponse(HttpResponse* response) if (!syncState) { - if (_dispatchOnWorkThread || std::this_thread::get_id() == Director::getInstance()->getCocos2dThreadId()) + if (_dispatchOnWorkThread || std::this_thread::get_id() == Director::getInstance()->getAxmolThreadId()) invokeResposneCallbackAndRelease(response); else _finishedResponseQueue.emplace_back(response); diff --git a/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp b/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp index d56a07cf73..e881f56345 100644 --- a/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -977,7 +977,7 @@ void TestIsFileExistAsync::onEnter() auto sharedFileUtils = FileUtils::getInstance(); sharedFileUtils->isFileExist("Images/grossini.png", [=](bool isExist) { - AXASSERT(std::this_thread::get_id() == Director::getInstance()->getCocos2dThreadId(), + AXASSERT(std::this_thread::get_id() == Director::getInstance()->getAxmolThreadId(), "Callback should be on cocos thread"); auto label = Label::createWithSystemFont( isExist ? "Images/grossini.png exists" : "Images/grossini.png doesn't exist", "", 20);