本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例12: readLock
bool TokenFactory::isAvailable(const Token & token)
{
ReadLock readLock( mMutex );
return
std::find(mAvailableTokens.begin(), mAvailableTokens.end(), token)
!= mAvailableTokens.end();
}
示例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;
}
示例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;
}
示例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;
}
}