当前位置: 首页>>代码示例>>C++>>正文


C++ readLock函数代码示例

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


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


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