• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ readLock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中readLock函数的典型用法代码示例。如果您正苦于以下问题:C++ readLock函数的具体用法?C++ readLock怎么用?C++ readLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readLock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetAnswerToRequest

VOID GetAnswerToRequest(const TSVNCacheRequest* pRequest, TSVNCacheResponse* pReply, DWORD* pResponseLength)
{
    CTSVNPath path;
    *pResponseLength = 0;
    if(pRequest->flags & TSVNCACHE_FLAGS_FOLDERISKNOWN)
    {
        path.SetFromWin(pRequest->path, !!(pRequest->flags & TSVNCACHE_FLAGS_ISFOLDER));
    }
    else
    {
        path.SetFromWin(pRequest->path);
    }

    CAutoReadWeakLock readLock(CSVNStatusCache::Instance().GetGuard(), 2000);

    if (readLock.IsAcquired())
    {
        CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": app asked for status of %s\n", pRequest->path);
        CSVNStatusCache::Instance().GetStatusForPath(path, pRequest->flags, false).BuildCacheResponse(*pReply, *pResponseLength);
    }
    else
    {
        CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": timeout for asked status of %s\n", pRequest->path);
        CStatusCacheEntry entry;
        entry.BuildCacheResponse(*pReply, *pResponseLength);
    }
}
开发者ID:webtronix1,项目名称:tortoisesvn,代码行数:27,代码来源:TSVNCache.cpp


示例2: lamexp_portable_mode

/*
 * Check for LameXP "portable" mode
 */
bool lamexp_portable_mode(void)
{
	QReadLocker readLock(&g_lamexp_portable.lock);

	if(g_lamexp_portable.bInitialized)
	{
		return g_lamexp_portable.bPortableModeEnabled;
	}
	
	readLock.unlock();
	QWriteLocker writeLock(&g_lamexp_portable.lock);

	if(!g_lamexp_portable.bInitialized)
	{
		if(VER_LAMEXP_PORTABLE_EDITION)
		{
			qWarning("LameXP portable edition!\n");
			g_lamexp_portable.bPortableModeEnabled = true;
		}
		else
		{
			QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName();
			int idx1 = baseName.indexOf("lamexp", 0, Qt::CaseInsensitive);
			int idx2 = baseName.lastIndexOf("portable", -1, Qt::CaseInsensitive);
			g_lamexp_portable.bPortableModeEnabled = (idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2);
		}
		g_lamexp_portable.bInitialized = true;
	}
	
	return g_lamexp_portable.bPortableModeEnabled;
}
开发者ID:manojkumardshenoy,项目名称:mulder,代码行数:34,代码来源:Global_Version.cpp


示例3: readLock

Cache::ApplyResult Cache::applyPolicy( CachePolicy& cachePolicy ) const
{
    ReadLock readLock( mutex_, boost::try_to_lock );
    if( !readLock.owns_lock() )
        return AR_CACHEBUSY;

    if( cacheMap_.empty() || !cachePolicy.willPolicyBeActivated( *this ) )
        return AR_NOTACTIVATED;

    std::vector< CacheObject* > cacheObjectList;
    cacheObjectList.reserve( cacheMap_.size() );

    for( CacheMap::const_iterator it = cacheMap_.begin(); it != cacheMap_.end(); ++it )
    {
        CacheObject* object = it->second.get();
        if( object && object->isValid() && object->isLoaded_() )
        {
            cacheObjectList.push_back( object );
        }
    }

    if( cacheObjectList.empty() )
        return AR_EMPTY;

    std::vector< CacheObject * > modifiedList;
    cachePolicy.apply_( *this, cacheObjectList, modifiedList );

    unloadCacheObjectsWithPolicy_( cachePolicy, modifiedList );
    return AR_ACTIVATED;
}
开发者ID:hernando,项目名称:Livre,代码行数:30,代码来源:Cache.cpp


示例4: do_all

		void do_all(boost::function<void(plugin_type)> fun) {
			boost::shared_lock<boost::shared_mutex> readLock(mutex_, boost::get_system_time() + boost::posix_time::seconds(5));
			if (!has_valid_lock_log(readLock, "plugins_list::list"))
				return;
			BOOST_FOREACH(const plugin_type p, plugins_) {
				fun(p);
			}
开发者ID:wyrover,项目名称:nscp,代码行数:7,代码来源:plugin_list.hpp


示例5: writeLock

TransferStats& 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,代码来源:Reporting.cpp


示例6: readLock

const TagFmt* EventTagMap::find(uint32_t tag) const {
  std::unordered_map<uint32_t, TagFmt>::const_iterator it;
  android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
  it = Idx2TagFmt.find(tag);
  if (it == Idx2TagFmt.end()) return NULL;
  return &(it->second);
}
开发者ID:MoKee,项目名称:android_system_core,代码行数:7,代码来源:event_tag_map.cpp


示例7: readLock

double HashContainer::getNthTheGreatestValue(unsigned int n)
{
	TimePoint tSearchGrStart = boost::chrono::high_resolution_clock::now();

	double rez = 0;
	unsigned int i = 0;

	ReadLock readLock(valuesLocker);

	ValuesSet::reverse_iterator iter = values.rbegin();

	if(iter != values.rend())
		rez = *iter;

	while(iter != values.rend())
	{
		if(rez != *iter)
			i++;

		rez = *iter;

		if(i == n)
			break;

		iter++;
	}

	TimePoint tSearchGrFinish = boost::chrono::high_resolution_clock::now();
	std::cout << "Search of " << n << "-th the greatest item took " << boost::chrono::duration_cast<boost::chrono::microseconds>(tSearchGrFinish - tSearchGrStart).count() << " microseconds\n";

	return rez;
}
开发者ID:pantuspavel,项目名称:hash,代码行数:32,代码来源:HashContainer.cpp


示例8: hash

double HashContainer::get(const string& key, bool withTimeMeasPrintout)
{
	HashContainer::TimePoint tStart;
	if(withTimeMeasPrintout)
		tStart = boost::chrono::high_resolution_clock::now();

	double rez = 0;

	unsigned int hashIndex = hash(key);
	SharedMutex* lock = bucketLocker[hashIndex];
	ReadLock readLock(*lock);
	
	Element* el = bucket[hashIndex];

	if(el)
	{
		if(el->getKey() == key)
		{
			rez = el->getValue();
		}
		else
		{
			rez = recursiveSearch(el, key);
		}
	}


	if(withTimeMeasPrintout)
	{
		HashContainer::TimePoint tFinish = boost::chrono::high_resolution_clock::now();
		std::cout << "Getting el with key = " << key << "; val = " << rez << " took " << boost::chrono::duration_cast<boost::chrono::microseconds>(tFinish - tStart).count() << " microseconds\n";
	}

	return rez;
}
开发者ID:pantuspavel,项目名称:hash,代码行数:35,代码来源:HashContainer.cpp


示例9: dataSource

void DataMatrix::_resetFieldStrings() {
  const QMap<QString, QString> meta_strings = dataSource()->matrix().metaStrings(_field);

  QStringList fieldStringKeys = _fieldStrings.keys();
  // remove field strings that no longer need to exist
  readLock();
  for (int i=0; i<fieldStringKeys.count(); i++) {
    QString key = fieldStringKeys.at(i);
    if (!meta_strings.contains(key)) {
      StringPtr sp = _fieldStrings[key];
      _fieldStrings.remove(key);
      sp = 0L;
    }
  }
  // find or insert strings, to set their value
  QMapIterator<QString, QString> it(meta_strings);
  while (it.hasNext()) {
    it.next();
    QString key = it.key();
    StringPtr sp;
    if (!_fieldStrings.contains(key)) { // insert a new one
      _fieldStrings.insert(key, sp = store()->createObject<String>());
      sp->setProvider(this);
      sp->setSlaveName(key);
    } else {  // find it
      sp = _fieldStrings[key];
    }
    sp->setValue(it.value());
  }
  unlock();
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:31,代码来源:datamatrix.cpp


示例10: readLock

double Book::prize(eris_time_t t) const {
    if (t < created_) return 0.0;
    auto lock = readLock();
    auto it = prize_.find(t);
    if (it == prize_.end()) return 0.0;
    return it->second;
}
开发者ID:erisproject,项目名称:creativity,代码行数:7,代码来源:Book.cpp


示例11: skipLock

static 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,代码来源:skiplist.c


示例12: readLock

 bool TokenFactory::isAvailable(const Token & token)
 {
     ReadLock readLock( mMutex );
     return 
         std::find(mAvailableTokens.begin(), mAvailableTokens.end(), token) 
         != mAvailableTokens.end();
 }
开发者ID:huangjunfeng2000,项目名称:Rcf,代码行数:7,代码来源:Token.cpp


示例13: readLock

    bool I_IpServerTransport::isIpAllowed(const IpAddress &ip) const
    {
        ReadLock readLock(mReadWriteMutex);

        if (!mAllowedIps.empty())
        {
            for (std::size_t i=0; i<mAllowedIps.size(); ++i)
            {
                if (ip.matches(mAllowedIps[i].first, mAllowedIps[i].second))
                {
                    return true;
                }
            }
            return false;
        }

        if (!mDisallowedIps.empty())
        {
            for (std::size_t i=0; i<mDisallowedIps.size(); ++i)
            {
                if (ip.matches(mDisallowedIps[i].first, mDisallowedIps[i].second))
                {
                    return false;
                }
            }
            return true;
        }

        return true;
    }    
开发者ID:Jack-Tsue,项目名称:OnlineWhiteBoard,代码行数:30,代码来源:IpServerTransport.cpp


示例14: lamexp_install_translator

/*
 * Install a new translator
 */
bool lamexp_install_translator(const QString &langId)
{
	bool success = false;
	const QString qmFileToPath(":/localization/%1");

	if(langId.isEmpty() || langId.toLower().compare(LAMEXP_DEFAULT_LANGID) == 0)
	{
		success = lamexp_install_translator_from_file(qmFileToPath.arg(LAMEXP_DEFAULT_TRANSLATION));
	}
	else
	{
		QReadLocker readLock(&g_lamexp_translation.lock);
		QString qmFile = (g_lamexp_translation.files) ? g_lamexp_translation.files->value(langId.toLower(), QString()) : QString();
		readLock.unlock();

		if(!qmFile.isEmpty())
		{
			success = lamexp_install_translator_from_file(qmFileToPath.arg(qmFile));
		}
		else
		{
			qWarning("Translation '%s' not available!", langId.toLatin1().constData());
		}
	}

	return success;
}
开发者ID:BackupTheBerlios,项目名称:lamexp,代码行数:30,代码来源:Global_Tools.cpp


示例15: lamexp_tool_version

/*
 * Lookup tool version
 */
unsigned int lamexp_tool_version(const QString &toolName, QString *tag)
{
	QReadLocker readLock(&g_lamexp_tools.lock);
	if(tag) tag->clear();

	if(g_lamexp_tools.versions)
	{
		if(g_lamexp_tools.versions->contains(toolName.toLower()))
		{
			if(tag)
			{
				if(g_lamexp_tools.tags->contains(toolName.toLower())) *tag = g_lamexp_tools.tags->value(toolName.toLower());
			}
			return g_lamexp_tools.versions->value(toolName.toLower());
		}
		else
		{
			return UINT_MAX;
		}
	}
	else
	{
		return UINT_MAX;
	}
}
开发者ID:BackupTheBerlios,项目名称:lamexp,代码行数:28,代码来源:Global_Tools.cpp


示例16: defaults

UsdGeomCamera
GusdOBJ_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,代码来源:OBJ_usdcamera.cpp


示例17: readLock

 bool I_IpServerTransport::isClientIpAllowed(const std::string &ip) const
 {
     ReadLock readLock(mReadWriteMutex);
     return
         mAllowedIps.empty() ||
         (std::find(mAllowedIps.begin(), mAllowedIps.end(), ip) !=
             mAllowedIps.end());
 }
开发者ID:r0ssar00,项目名称:iTunesSpeechBridge,代码行数:8,代码来源:IpServerTransport.cpp


示例18: readLock

nsclient::core::plugin_cache::plugin_cache_list_type nsclient::core::plugin_cache::get_list() {
	boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::seconds(5));
	if (!readLock.owns_lock()) {
		LOG_ERROR_CORE("FATAL ERROR: Could not get read-mutex.");
		return plugin_cache_list_type();
	}
	return plugin_cache_list_type(plugin_cache_.begin(), plugin_cache_.end());
}
开发者ID:wyrover,项目名称:nscp,代码行数:8,代码来源:plugin_cache.cpp


示例19: readLock

 StubFactoryPtr StubFactoryRegistry::getStubFactory(
     const std::string &objectName)
 {
     ReadLock readLock(mStubFactoryMapMutex);
     return mStubFactoryMap.find(objectName)  != mStubFactoryMap.end() ?
         mStubFactoryMap[objectName] :
         StubFactoryPtr();
 }
开发者ID:MorelM35,项目名称:ESIR_MorKaneGame,代码行数:8,代码来源:ObjectFactoryService.cpp


示例20: readLock

void MsgHandler::Invoke(const IMsg *pMsg)
{
    ReadLock readLock(m_rwMutex);
    SigPunmap::iterator iter = m_sigPunmap.find(pMsg->ClassName());
    if (iter != m_sigPunmap.end())
    {
	(*(iter->second))(pMsg);
    }
}
开发者ID:mzxdream,项目名称:BlueHand,代码行数:9,代码来源:MsgHandler.cpp



注:本文中的readLock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ readLong函数代码示例发布时间:2022-05-30
下一篇:
C++ readLine函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap