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


C++ writeLock函数代码示例

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


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

示例1: computeStrategy1

void Matrix::randomize()
{
    const int dev = computeStrategy1();
    writeLock(dev);
    matty::getDevice(dev)->randomize(getArray(dev));
    writeUnlock(dev);
}
开发者ID:pthibaud,项目名称:MicroMagnum,代码行数:7,代码来源:Matrix.cpp

示例2: writeLock

bool
MM_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,代码来源:HeapRegionManagerTarok.cpp

示例3: 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

示例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,代码来源:iv_AllosphereTexture.cpp

示例5: writeLock

void 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,代码来源:TerrainCache.cpp

示例6: writeLock

void
Printer::wait() {
	std::unique_lock<std::mutex> writeLock(writeMutex);
	while(commandQueue.size() > 0) {
		signalNextCommand.wait(writeLock);
	}
}
开发者ID:fablab-bayreuth,项目名称:repetier-library,代码行数:7,代码来源:Printer.cpp

示例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,代码来源:repl_set_impl.cpp

示例8: 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

示例9: lock

ShTimeStream::~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,代码来源:shtimestream.cpp

示例10: hash

void 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,代码来源:HashContainer.cpp

示例11: writeLock

///////////////////////////PRIVATE///////////////////////////////////
void
PluginXmlParser::addPluginToList(StatusPluginReference* pluginContainer)
{
    OsWriteLock writeLock(mListMutexW);

    mPluginTable.insert(pluginContainer);
}
开发者ID:LordGaav,项目名称:sipxecs,代码行数:8,代码来源:PluginXmlParser.cpp

示例12: defined

void DNS::reload()
{
#if defined(POCO_HAVE_LIBRESOLV)
	Poco::ScopedWriteRWLock writeLock(resolverLock);
	res_init();
#endif
}
开发者ID:12307,项目名称:poco,代码行数:7,代码来源:DNS.cpp

示例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,代码来源:IpServerTransport.cpp

示例14: throw

void 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,代码来源:SReadArray.cpp

示例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,代码来源:Global_Tools.cpp


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