这篇教程C++ writeLock函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中writeLock函数的典型用法代码示例。如果您正苦于以下问题:C++ writeLock函数的具体用法?C++ writeLock怎么用?C++ writeLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了writeLock函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: computeStrategy1void Matrix::randomize(){ const int dev = computeStrategy1(); writeLock(dev); matty::getDevice(dev)->randomize(getArray(dev)); writeUnlock(dev);}
开发者ID:pthibaud,项目名称:MicroMagnum,代码行数:7,
示例2: writeLockboolMM_HeapRegionManagerTarok::setContiguousHeapRange(MM_EnvironmentBase *env, void *lowHeapEdge, void *highHeapEdge){ writeLock(); /* ensure that this manager was configured with a valid region size */ Assert_MM_true(0 != _regionSize); /* we don't yet support multiple enabling calls (split heaps) */ /* This assertion would triggered at multiple attempts to initialize heap in gcInitializeDefaults() */ /* Assert_MM_true(NULL == _regionTable); */ /* the regions must be aligned (in present implementation) */ Assert_MM_true(0 == ((uintptr_t)lowHeapEdge % _regionSize)); Assert_MM_true(0 == ((uintptr_t)highHeapEdge % _regionSize)); /* make sure that the range is in the right order and of non-zero size*/ Assert_MM_true(highHeapEdge > lowHeapEdge); /* allocate the table */ uintptr_t size = (uintptr_t)highHeapEdge - (uintptr_t)lowHeapEdge; _tableRegionCount = size / _regionSize; _regionTable = internalAllocateAndInitializeRegionTable(env, lowHeapEdge, highHeapEdge); bool success = false; if (NULL != _regionTable) { _lowTableEdge = lowHeapEdge; _highTableEdge = highHeapEdge; success = true; } writeUnlock(); return success;}
开发者ID:LinHu2016,项目名称:omr,代码行数:27,
示例3: skipLockstatic skipItem skipLock(skipList list, UINT32 key, skipItem *save, INT32 top) { INT32 i; skipItem x, y; if(list->threaded) readLock(list); x = list->header; /* header contains all levels */ for(i = top; /* loop from top level down to level 0 */ i >= 0; i--) { y = x->next[i]; /* get next item at this level */ while(y->key < key) { /* if y has a smaller key, try the next item */ x = y; /* save x in case we overshoot */ y = x->next[i]; /* get next item */ } save[i] = x; /* preserve item with next pointer in save */ } if(list->threaded) writeLock(list); /* lock list for update */ /* validate we have the closest previous item */ return skipClosest(x, key, 0);}
开发者ID:0omega,项目名称:platform_external_clearsilver,代码行数:30,
示例4: upload bool upload(void* image, int width, int height) { if(!writeLock()) return false; metadata->timestamp = get_precise_time(); memcpy(pixels, image, width * height * 4); writeUnlock(); return true; }
开发者ID:donghaoren,项目名称:Node-AlloSystem,代码行数:7,
示例5: writeLockvoid TerrainCache::clear(TerrainGenerator* generator) { float centerX, centerY, radius; bool result = generator->getFullBoundaryCircle(centerX, centerY, radius); //assert(result); if (!result) return; Vector<QuadTreeEntryInterface*> heightsToDelete; Locker writeLock(getLock()); ++clearCount; clearHeightsCount += quadTree.inRange(centerX, centerY, radius, heightsToDelete); for (int i = 0; i < heightsToDelete.size(); ++i) { HeightQuadTreeEntry* entry = static_cast<HeightQuadTreeEntry*>(heightsToDelete.get(i)); remove(entry->getObjectID()); quadTree.remove(entry); delete entry; }}
开发者ID:Marott1,项目名称:Core3,代码行数:28,
示例6: writeLockvoidPrinter::wait() { std::unique_lock<std::mutex> writeLock(writeMutex); while(commandQueue.size() > 0) { signalNextCommand.wait(writeLock); }}
开发者ID:fablab-bayreuth,项目名称:repetier-library,代码行数:7,
示例7: replLock bool ReplSetImpl::setMaintenanceMode(OperationContext* txn, const bool inc) { lock replLock(this); // Lock here to prevent state from changing between checking the state and changing it Lock::GlobalWrite writeLock(txn->lockState()); if (box.getState().primary()) { return false; } if (inc) { log() << "replSet going into maintenance mode (" << _maintenanceMode << " other tasks)" << rsLog; _maintenanceMode++; changeState(MemberState::RS_RECOVERING); } else if (_maintenanceMode > 0) { _maintenanceMode--; // no need to change state, syncTail will try to go live as a secondary soon log() << "leaving maintenance mode (" << _maintenanceMode << " other tasks)" << rsLog; } else { return false; } fassert(16844, _maintenanceMode >= 0); return true; }
开发者ID:Rockyit,项目名称:mongo,代码行数:30,
示例8: writeLockTransferStats& TransferStats::operator+=(const TransferStats& stats) { folly::RWSpinLock::WriteHolder writeLock(mutex_.get()); folly::RWSpinLock::ReadHolder readLock(stats.mutex_.get()); headerBytes_ += stats.headerBytes_; dataBytes_ += stats.dataBytes_; effectiveHeaderBytes_ += stats.effectiveHeaderBytes_; effectiveDataBytes_ += stats.effectiveDataBytes_; numFiles_ += stats.numFiles_; numBlocks_ += stats.numBlocks_; failedAttempts_ += stats.failedAttempts_; if (stats.errCode_ != OK) { if (errCode_ == OK) { // First error. Setting this as the error code errCode_ = stats.errCode_; } else if (stats.errCode_ != errCode_) { // Different error than the previous one. Setting error code as generic // ERROR errCode_ = ERROR; } } if (stats.remoteErrCode_ != OK) { if (remoteErrCode_ == OK) { remoteErrCode_ = stats.remoteErrCode_; } else if (stats.remoteErrCode_ != remoteErrCode_) { remoteErrCode_ = ERROR; } } return *this;}
开发者ID:electrum,项目名称:wdt,代码行数:29,
示例9: lockShTimeStream::~ShTimeStream(){ boost::upgrade_lock<boost::shared_mutex> lock(mutex); boost::upgrade_to_unique_lock<boost::shared_mutex> writeLock(lock); std::list<ShTimeEvent*>::iterator eventIter = timeEvents.begin(); while(eventIter != timeEvents.end()) { delete *eventIter; ++eventIter; } timeEvents.clear(); std::list<ShTimeStream*>::iterator branchIter = timeBranches.begin(); while(branchIter != timeBranches.end()) { delete *branchIter; ++branchIter; } timeBranches.clear();}
开发者ID:ChadMcKinney,项目名称:Shoggoth,代码行数:25,
示例10: hashvoid HashContainer::insert(const string& key, double val, bool withTimeMeasPrintout){ HashContainer::TimePoint tStart; if(withTimeMeasPrintout) tStart = boost::chrono::high_resolution_clock::now(); unsigned int hashIndex = hash(key); SharedMutex* lock = bucketLocker[hashIndex]; WriteLock writeLock(*lock); Element* el = bucket[hashIndex]; if(el) { updateOrAppend(el, key, val); } else { Element* newEl = new Element(); newEl->setKey(key); newEl->setValue(val); bucket[hashIndex] = newEl; } WriteLock valuesWriteLock(valuesLocker); values.insert(val); if(withTimeMeasPrintout) { HashContainer::TimePoint tFinish = boost::chrono::high_resolution_clock::now(); std::cout << "Inserting el with key = " << key << "; val = " << val << " took " << boost::chrono::duration_cast<boost::chrono::microseconds>(tFinish - tStart).count() << " microseconds/n"; }}
开发者ID:pantuspavel,项目名称:hash,代码行数:33,
示例11: writeLock///////////////////////////PRIVATE///////////////////////////////////voidPluginXmlParser::addPluginToList(StatusPluginReference* pluginContainer){ OsWriteLock writeLock(mListMutexW); mPluginTable.insert(pluginContainer);}
开发者ID:LordGaav,项目名称:sipxecs,代码行数:8,
示例12: definedvoid DNS::reload(){#if defined(POCO_HAVE_LIBRESOLV) Poco::ScopedWriteRWLock writeLock(resolverLock); res_init();#endif}
开发者ID:12307,项目名称:poco,代码行数:7,
示例13: writeLock void I_IpServerTransport::setAllowedClientIps( const std::vector<std::string> &allowedClientIps) { WriteLock writeLock(mReadWriteMutex); mAllowedIps.assign(allowedClientIps.begin(), allowedClientIps.end()); // translate the ips into 32 bit values, network order mAllowedAddrs.clear(); for (unsigned int i=0; i<mAllowedIps.size(); i++) { const std::string &ip = mAllowedIps[i]; hostent *hostDesc = ::gethostbyname( ip.c_str() ); if (hostDesc == NULL) { int err = Platform::OS::BsdSockets::GetLastError(); std::string strErr = Platform::OS::GetErrorString(err); RCF_TRACE("gethostbyname() failed")(ip)(err)(strErr); mAllowedAddrs.push_back(INADDR_NONE); } else { in_addr addr = *((in_addr*) hostDesc->h_addr_list[0]); mAllowedAddrs.push_back(addr.s_addr); } } }
开发者ID:r0ssar00,项目名称:iTunesSpeechBridge,代码行数:26,
示例14: throwvoid SReadArray::updating() throw( ::fwTools::Failed ){ ::fwData::Array::sptr array = this->getObject< ::fwData::Array >(); ::fwData::mt::ObjectWriteLock writeLock(array); SLM_ASSERT("No array.", array); const int arraySize = 10; ::fwData::Array::SizeType size(1, arraySize); array->resize("uint32", size, 1, true); ::fwComEd::helper::Array arrayHelper(array); unsigned int *buffer = static_cast< unsigned int* >( arrayHelper.getBuffer() ); for (int i = 0 ; i < arraySize; i++) { buffer[i] = i; } ::fwData::Object::ObjectModifiedSignalType::sptr sig = array->signal< ::fwData::Object::ObjectModifiedSignalType>( ::fwData::Object::s_OBJECT_MODIFIED_SIG ); ::fwServices::ObjectMsg::sptr msg = ::fwServices::ObjectMsg::New(); msg->addEvent("MODIFIED_EVENT"); sig->asyncEmit(msg);}
开发者ID:corentindesfarges,项目名称:fw4spl,代码行数:28,
示例15: lamexp_install_translator_from_file/* * Install a new translator from file */bool lamexp_install_translator_from_file(const QString &qmFile){ QWriteLocker writeLock(&g_lamexp_currentTranslator.lock); bool success = false; if(!g_lamexp_currentTranslator.instance) { g_lamexp_currentTranslator.instance = new QTranslator(); } if(!qmFile.isEmpty()) { QString qmPath = QFileInfo(qmFile).canonicalFilePath(); QApplication::removeTranslator(g_lamexp_currentTranslator.instance); if(success = g_lamexp_currentTranslator.instance->load(qmPath)) { QApplication::installTranslator(g_lamexp_currentTranslator.instance); } else { qWarning("Failed to load translation:/n/"%s/"", qmPath.toLatin1().constData()); } } else { QApplication::removeTranslator(g_lamexp_currentTranslator.instance); success = true; } return success;}
开发者ID:BackupTheBerlios,项目名称:lamexp,代码行数:34,
示例16: writeLock void ReplSetImpl::relinquish(OperationContext* txn) { { Lock::GlobalWrite writeLock(txn->lockState()); // so we are synchronized with _logOp() LOG(2) << "replSet attempting to relinquish" << endl; if (box.getState().primary()) { log() << "replSet relinquishing primary state" << rsLog; changeState(MemberState::RS_SECONDARY); // close sockets that were talking to us so they don't blithly send many writes that // will fail with "not master" (of course client could check result code, but in // case they are not) log() << "replSet closing client sockets after relinquishing primary" << rsLog; MessagingPort::closeAllSockets(ScopedConn::keepOpen); } else if (box.getState().startup2()) { // This block probably isn't necessary changeState(MemberState::RS_RECOVERING); return; } } // now that all connections were closed, strip this mongod from all sharding details if and // when it gets promoted to a primary again, only then it should reload the sharding state // the rationale here is that this mongod won't bring stale state when it regains // primaryhood shardingState.resetShardingState(); }
开发者ID:JsonRuby,项目名称:mongo,代码行数:28,
示例17: defaultsUsdGeomCameraGusdOBJ_usdcamera::_LoadCamera(fpreal t, int thread){ /* XXX: Disallow camera loading until the scene has finished loading. What happens otherwise is that some parm values are pulled on during loading, causing a _LoadCamera request. If this happens before the node's parm values have been loaded, then we'll end up loading the camera using defaults (which reference the shot conversion). So if we don't block this, we end up always loading the shot conversion, even if we don't need it! */ if(_isLoading) return UsdGeomCamera(); /* Always return a null camera while saving. This is to prevent load errors from prematurely interrupting saves, which can lead to corrupt files.*/ if(GusdUTverify_ptr(OPgetDirector())->getIsDoingExplicitSave()) return UsdGeomCamera(); { UT_AutoReadLock readLock(_lock); if(!_camParmsMicroNode.requiresUpdate(t)) return _cam; } UT_AutoWriteLock writeLock(_lock); /* Other thread may already have loaded the cam, so only update if needed.*/ if(_camParmsMicroNode.updateIfNeeded(t, thread)) { _errors.clearAndDestroyErrors(); _cam = UsdGeomCamera(); GusdPRM_Shared prmShared; UT_String usdPath, primPath; evalStringT(usdPath, prmShared->filePathName.getToken(), 0, t, thread); evalStringT(primPath, prmShared->primPathName.getToken(), 0, t, thread); GusdUT_ErrorManager errMgr(_errors); GusdUT_ErrorContext err(errMgr); GusdStageCacheReader cache; if(UsdPrim prim = cache.GetPrimWithVariants( usdPath, primPath, GusdStageOpts::LoadAll(), &err).first) { // Track changes to the stage (eg., reloads) DEP_MicroNode* stageMicroNode = cache.GetStageMicroNode(prim.GetStage()); UT_ASSERT_P(stageMicroNode); _camParmsMicroNode.addExplicitInput(*stageMicroNode); _cam = GusdUSD_Utils::MakeSchemaObj<UsdGeomCamera>(prim, &err); return _cam; } } return UsdGeomCamera();}
开发者ID:lvxejay,项目名称:USD,代码行数:59,
示例18: writeLockvoid EntityEditFilters::removeFilter(EntityItemID entityID) { QWriteLocker writeLock(&_lock); FilterData filterData = _filterDataMap.value(entityID); if (filterData.valid()) { delete filterData.engine; } _filterDataMap.remove(entityID);}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:8,
示例19: writeLockvoid nsclient::core::plugin_cache::add_plugin(nsclient::core::plugin_type plugin) { boost::unique_lock<boost::shared_mutex> writeLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(5)); if (!writeLock.owns_lock()) { LOG_ERROR_CORE("FATAL ERROR: Could not get write-mutex."); return; } plugin_cache_.push_back(plugin_cache_item(plugin));}
开发者ID:wyrover,项目名称:nscp,代码行数:8,
示例20: lockvoid ShTimer::stop(){ boost::upgrade_lock<boost::shared_mutex> lock(timerMutex); boost::upgrade_to_unique_lock<boost::shared_mutex> writeLock(lock); running = false; //std::cout << "ShTimer FINISHED JOIN" << std::endl; //std::cout << "ShTimer stopped" << std::endl;}
开发者ID:ChadMcKinney,项目名称:Shoggoth,代码行数:8,
示例21: writeLockvoid MUPD::intraApply() { auto lock = writeLock(con); for (auto &res: reservations) { res.buy(); } reservations.clear();}
开发者ID:erisproject,项目名称:eris,代码行数:9,
示例22: writeLockCCachedDirectory * CSVNStatusCache::GetDirectoryCacheEntry(const CTSVNPath& path){ CCachedDirectory::ItDir itMap = m_directoryCache.find(path); if ((itMap != m_directoryCache.end())&&(itMap->second)) { // We've found this directory in the cache return itMap->second; } else { // if the CCachedDirectory is NULL but the path is in our cache, // that means that path got invalidated and needs to be treated // as if it never was in our cache. So we remove the last remains // from the cache and start from scratch. CAutoWriteLock writeLock(m_guard); // Since above there's a small chance that before we can upgrade to // writer state some other thread gained writer state and changed // the data, we have to recreate the iterator here again. itMap = m_directoryCache.find(path); if (itMap!=m_directoryCache.end()) { delete itMap->second; m_directoryCache.erase(itMap); } // We don't know anything about this directory yet - lets add it to our cache // but only if it exists! if (path.Exists() && m_shellCache.IsPathAllowed(path.GetWinPath()) && !g_SVNAdminDir.IsAdminDirPath(path.GetWinPath())) { // some notifications are for files which got removed/moved around. // In such cases, the CTSVNPath::IsDirectory() will return true (it assumes a directory if // the path doesn't exist). Which means we can get here with a path to a file // instead of a directory. // Since we're here most likely called from the crawler thread, the file could exist // again. If that's the case, just do nothing if (path.IsDirectory()||(!path.Exists())) { std::unique_ptr<CCachedDirectory> newcdir (new CCachedDirectory (path)); if (newcdir.get()) { itMap = m_directoryCache.lower_bound (path); ASSERT ( (itMap == m_directoryCache.end()) || (itMap->path != path)); itMap = m_directoryCache.insert (itMap, std::make_pair (path, newcdir.release())); if (!path.IsEmpty()) CSVNStatusCache::Instance().AddFolderForCrawling(path); return itMap->second; } m_bClearMemory = true; } } return NULL; }}
开发者ID:code-mx,项目名称:tortoisesvn,代码行数:57,
示例23: writeLockvoid HashContainer::removeOneValueFromValues(double val){ // Need to eraze only one entrance of the value WriteLock writeLock(valuesLocker); ValuesSet::iterator it = values.find(val); values.erase(it);}
开发者ID:pantuspavel,项目名称:hash,代码行数:9,
示例24: computeStrategy1void VectorMatrix::randomize(){ const int dev = computeStrategy1(); writeLock(dev); for (int c=0; c<num_arrays; ++c) { matty::getDevice(dev)->randomize(getArray(dev, c)); } writeUnlock(dev);}
开发者ID:MicroMagnum,项目名称:MicroMagnum,代码行数:9,
示例25: writeLock void PublishingService::closePublisher(const std::string & name) { Lock writeLock(mPublishersMutex); Publishers::iterator iter = mPublishers.find(name); if (iter != mPublishers.end()) { mPublishers.erase(iter); } }
开发者ID:crazyguymkii,项目名称:SWGEmuRPCServer,代码行数:9,
示例26: RCF_UNUSED_VARIABLE bool StubFactoryRegistry::insertStubFactory( const std::string &objectName, const std::string &desc, StubFactoryPtr stubFactoryPtr) { RCF_UNUSED_VARIABLE(desc); WriteLock writeLock(mStubFactoryMapMutex); mStubFactoryMap[ objectName ] = stubFactoryPtr; return true; }
开发者ID:MorelM35,项目名称:ESIR_MorKaneGame,代码行数:10,
注:本文中的writeLock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ writeLong函数代码示例 C++ writeLine函数代码示例 |