void ReallocLexicon::clear() { bool mustReleaseWriteLock = getWriteLock(); // release all resources for (int i = 0; i < termCount; i++) if (terms[i].postings != NULL) free(terms[i].postings); free(terms); termCount = 0; termSlotsAllocated = INITIAL_SLOT_COUNT; terms = typed_malloc(ReallocLexiconEntry, termSlotsAllocated); // virginize hashtable for (int i = 0; i < HASHTABLE_SIZE; i++) hashtable[i] = -1; // update occupied memory information memoryOccupied = termSlotsAllocated * sizeof(ReallocLexiconEntry); memoryOccupied += HASHTABLE_SIZE * sizeof(int32_t); // update coverage information firstPosting = MAX_OFFSET; lastPosting = 0; if (mustReleaseWriteLock) releaseWriteLock(); } // end of clear()
QString SimpleJsonDB::jsonString() { acquireWriteLock(); QString dbString = db->toJson(QMJsonFormat_Pretty, QMJsonSort_CaseSensitive); if (filterVmAndDomstoreKeys) { auto filteredValue = QMJsonValue::fromJson(dbString); if (filteredValue.isNull()) { qCritical("unable to convert db string to qmjsonvalue!"); exit(1); } if (!filteredValue->isObject()) { qCritical("db qmjsonvalue is not an object!"); exit(1); } filteredValue->toObject()->remove("vm"); filteredValue->toObject()->remove("dom-store"); dbString = filteredValue->toJson(QMJsonFormat_Pretty, QMJsonSort_CaseSensitive); } releaseWriteLock(); return dbString; }
void SimpleJsonDB::readFromDisk() { acquireWriteLock(); if (path != ":memory:") { QFile dbFile(path); if (dbFile.exists()) { db = QMJsonValue::fromJsonFile(path); qDebug() << "db from json file:" << db; // XXX: fix desired https://github.com/QtMark/qmjson/issues/9 if (db.isNull() || !db->isObject()) { // save off bad db file for later review, but do not abort // this is preferable than failing to boot if dbd doesn't come up qCritical() << "failed to read db:" << path << "malformed?" << dbFile.readAll(); qCritical() << "moving bad db from:" << path << "to:" << path + ".bad"; dbFile.rename(path + ".bad"); } } } // if no json file exists, create empty object if (db.isNull() || !db->isObject()) { qDebug() << "creating default empty object for db:" << path; auto obj = QMPointer<QMJsonObject>(new QMJsonObject()); db = QMPointer<QMJsonValue>(new QMJsonValue(obj)); } releaseWriteLock(); }
void PxWorld::releaseClothMesh( NxClothMesh &clothMesh ) { // We need the writelock to release. releaseWriteLock(); gPhysicsSDK->releaseClothMesh( clothMesh ); }
NxController* PxWorld::createController( NxControllerDesc &desc ) { if ( !mScene ) return NULL; // We need the writelock! releaseWriteLock(); return mControllerManager->createController( mScene, desc ); }
physx::PxController* Px3World::createController( physx::PxControllerDesc &desc ) { if ( !mScene ) return NULL; // We need the writelock! releaseWriteLock(); physx::PxController* pController = mControllerManager->createController(desc); AssertFatal( pController, "Px3World::createController - Got a null!" ); return pController; }
void PxWorld::releaseController( NxController &controller ) { // TODO: This isn't safe to do with actors and // joints, so we probably need a queue like we // do for them. // We need the writelock to release. releaseWriteLock(); mControllerManager->releaseController( controller ); }
NxMaterial* PxWorld::createMaterial( NxMaterialDesc &material ) { if ( !mScene ) return NULL; // We need the writelock to create a material! releaseWriteLock(); NxMaterial *mat = mScene->createMaterial( material ); if ( !mat ) return NULL; return mat; }