mirror of https://github.com/axmolengine/axmol.git
/* axmol thread id */ (#924)
This commit is contained in:
parent
bdbe9b4f6f
commit
eb5058e6d0
|
@ -1461,7 +1461,7 @@ void Director::startAnimation(SetIntervalReason reason)
|
||||||
|
|
||||||
_invalid = false;
|
_invalid = false;
|
||||||
|
|
||||||
_cocos2d_thread_id = std::this_thread::get_id();
|
_axmol_thread_id = std::this_thread::get_id();
|
||||||
|
|
||||||
Application::getInstance()->setAnimationInterval(_animationInterval);
|
Application::getInstance()->setAnimationInterval(_animationInterval);
|
||||||
|
|
||||||
|
|
|
@ -488,10 +488,11 @@ public:
|
||||||
void resetMatrixStack();
|
void resetMatrixStack();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the cocos2d thread id.
|
* returns the axmol thread id.
|
||||||
Useful to know if certain code is already running on the cocos2d thread
|
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
|
/** Enable node tree children indexer map, the concept is like database INDEX
|
||||||
* Notes:
|
* Notes:
|
||||||
|
@ -644,8 +645,8 @@ protected:
|
||||||
|
|
||||||
bool _childrenIndexerEnabled = false;
|
bool _childrenIndexerEnabled = false;
|
||||||
|
|
||||||
/* cocos2d thread id */
|
/* axmol thread id */
|
||||||
std::thread::id _cocos2d_thread_id;
|
std::thread::id _axmol_thread_id;
|
||||||
|
|
||||||
// GLView will recreate stats labels to fit visible rect
|
// GLView will recreate stats labels to fit visible rect
|
||||||
friend class GLView;
|
friend class GLView;
|
||||||
|
|
|
@ -465,7 +465,7 @@ void HttpClient::finishResponse(HttpResponse* response)
|
||||||
|
|
||||||
if (!syncState)
|
if (!syncState)
|
||||||
{
|
{
|
||||||
if (_dispatchOnWorkThread || std::this_thread::get_id() == Director::getInstance()->getCocos2dThreadId())
|
if (_dispatchOnWorkThread || std::this_thread::get_id() == Director::getInstance()->getAxmolThreadId())
|
||||||
invokeResposneCallbackAndRelease(response);
|
invokeResposneCallbackAndRelease(response);
|
||||||
else
|
else
|
||||||
_finishedResponseQueue.emplace_back(response);
|
_finishedResponseQueue.emplace_back(response);
|
||||||
|
|
|
@ -977,7 +977,7 @@ void TestIsFileExistAsync::onEnter()
|
||||||
auto sharedFileUtils = FileUtils::getInstance();
|
auto sharedFileUtils = FileUtils::getInstance();
|
||||||
|
|
||||||
sharedFileUtils->isFileExist("Images/grossini.png", [=](bool isExist) {
|
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");
|
"Callback should be on cocos thread");
|
||||||
auto label = Label::createWithSystemFont(
|
auto label = Label::createWithSystemFont(
|
||||||
isExist ? "Images/grossini.png exists" : "Images/grossini.png doesn't exist", "", 20);
|
isExist ? "Images/grossini.png exists" : "Images/grossini.png doesn't exist", "", 20);
|
||||||
|
|
Loading…
Reference in New Issue