void StringCache::setWeakCallback(const v8::WeakCallbackData<v8::String, StringImpl>& data) { StringCache* stringCache = V8PerIsolateData::from(data.GetIsolate())->stringCache(); stringCache->m_lastStringImpl = 0; stringCache->m_lastV8String.clear(); ASSERT(stringCache->m_stringCache.contains(data.GetParameter())); stringCache->m_stringCache.get(data.GetParameter()).dispose(); stringCache->m_stringCache.remove(data.GetParameter()); data.GetParameter()->deref(); }
static void WeakCollectionCallback (const v8::WeakCallbackData<v8::External, v8::Persistent<v8::External>>& data) { auto isolate = data.GetIsolate(); auto persistent = data.GetParameter(); auto myCollection = v8::Local<v8::External>::New(isolate, *persistent); auto collection = static_cast<TRI_vocbase_col_t*>(myCollection->Value()); TRI_GET_GLOBALS(); v8g->_hasDeadObjects = true; // decrease the reference-counter for the database TRI_ReleaseVocBase(collection->_vocbase); // find the persistent handle #if TRI_ENABLE_MAINTAINER_MODE map<void*, v8::Persistent<v8::External>>::iterator it = v8g->JSCollections.find(collection); TRI_ASSERT(it != v8g->JSCollections.end()) #endif if (! collection->_isLocal) { FreeCoordinatorCollection(collection); } // dispose and clear the persistent handle v8g->JSCollections[collection].Reset(); v8g->JSCollections.erase(collection); }