/* axmol thread id */ (#924)

This commit is contained in:
aismann 2022-10-12 01:04:36 +02:00 committed by GitHub
parent bdbe9b4f6f
commit eb5058e6d0
4 changed files with 9 additions and 8 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);