bool ItemJSBinding::addExtender(ChromiumDLL::JavaScriptExtenderI* extender) { if (!extender) return false; bool found = false; g_ItemLock.lock(); for (size_t x=0; x<g_vExtenderList.size(); x++) { if (g_vExtenderList[x] == extender) { found = true; break; } } if (!found) g_vExtenderList.push_back(extender); g_ItemLock.unlock(); return !found; }
uint32 ItemJSBinding::AddItem(ScriptCoreItemI* item) { uint32 hash = UTIL::MISC::RSHash_CSTR(gcString("{0}", (uint64)item)); g_ItemLock.lock(); g_ItemMap[hash] = item; g_ItemLock.unlock(); return hash; }
void ItemJSBinding::RemoveItem(uint32 itemId) { g_ItemLock.lock(); auto it = g_ItemMap.find(itemId); if (it != g_ItemMap.end()) g_ItemMap.erase(it); g_ItemLock.unlock(); }
ScriptCoreItemI* ItemJSBinding::GetItem(uint32 itemId) { ScriptCoreItemI* ret = NULL; g_ItemLock.lock(); auto it = g_ItemMap.find(itemId); if (it != g_ItemMap.end()) ret= it->second; g_ItemLock.unlock(); return ret; }
const char* ItemJSBinding::getRegistrationCode() { DesuraJSBase<ItemJSBinding>::getRegistrationCode(); g_ItemLock.lock(); for (size_t x=0; x<g_vExtenderList.size(); x++) { const char* code = g_vExtenderList[x]->getRegistrationCode(); m_szRegCode.append(code); } g_ItemLock.unlock(); return m_szRegCode.c_str(); }
JSObjHandle ItemJSBinding::execute(ChromiumDLL::JavaScriptFunctionArgs* args) { JSObjHandle ret = DesuraJSBase<ItemJSBinding>::execute(args); if (!ret->isException() || g_vExtenderList.empty()) return ret; g_ItemLock.lock(); for (size_t x=0; x<g_vExtenderList.size(); x++) { ret = g_vExtenderList[x]->execute(args); if (!ret->isException()) break; } g_ItemLock.unlock(); return ret; }
void log(const std::string& message) { mutex.lock(); os << "logger: " << message << "\n"; mutex.unlock(); }
void WildcardManager::needSpecial(WCSpecialInfo *info) { m_WCMutex.lock(); onNeedSpecialEvent(*info); m_WCMutex.unlock(); }