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


C++ boost::shared_mutex类代码示例

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


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

示例1:

 safeprint&  operator<<(const std::string& msg) {
     cout_lock.lock_shared();
     std::cout << msg;
     cout_lock.unlock();
     //std::cout << "public safe" << std::endl;
     return *this;
 }
开发者ID:ottolote,项目名称:TTK4145,代码行数:7,代码来源:safeprint.hpp

示例2: removeTrack

bool TrackManager::removeTrack( int pIndex)
{
	mySharedMutex.lock();
	bool isRemoved = myController->getTrackList()->removeObjById( pIndex);
	myController->createIndex();
	mySharedMutex.unlock();
	return isRemoved;
}
开发者ID:johnjohndoe,项目名称:Programming,代码行数:8,代码来源:TrackManager.cpp

示例3: newDataAvailable

	void StatisticsMultiplexerSync::newDataAvailable() throw() {
		listenersLock.lock_shared();
		for( size_t i = listeners.size(); i--; ) {
			ListenerData& cur = listeners[i];
			cur.listener->newDataAvailable();
		}
		listenersLock.unlock_shared();
	}
开发者ID:JulianKunkel,项目名称:siox,代码行数:8,代码来源:StatisticsMultiplexerSync.cpp

示例4: notifyAvailableStatisticsChange

	void StatisticsMultiplexerSync::notifyAvailableStatisticsChange( const std::vector<std::shared_ptr<Statistic> > & statistics, bool addedStatistics, bool removedStatistics ) throw() {
		listenersLock.lock_shared();
		for( size_t i = listeners.size(); i--; ) {
			ListenerData& cur = listeners[i];
			cur.listener->notifyAvailableStatisticsChange( statistics, addedStatistics, removedStatistics );
		}
		lastStatistics = & statistics;
		listenersLock.unlock_shared();
	}
开发者ID:JulianKunkel,项目名称:siox,代码行数:9,代码来源:StatisticsMultiplexerSync.cpp

示例5: unregisterListener

	void StatisticsMultiplexerSync::unregisterListener( StatisticsMultiplexerListener * listener ) throw() {
		listenersLock.lock();
		for( size_t i = listeners.size(); i--; ) {
			if( listeners[i].listener == listener ) {
				listeners.erase(listeners.begin() + i);
			}
		}
		listenersLock.unlock();
	}
开发者ID:JulianKunkel,项目名称:siox,代码行数:9,代码来源:StatisticsMultiplexerSync.cpp

示例6: f1

void f1()
{
  time_point t0 = Clock::now();
  // This test is spurious as it depends on the time the thread system switches the threads
  BOOST_TEST(m.try_lock_until(Clock::now() + ms(300) + ms(1000)) == true);
  time_point t1 = Clock::now();
  m.unlock();
  ns d = t1 - t0 - ms(250);
  BOOST_TEST(d < ns(5000000)+ms(1000)); // within 5ms
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:10,代码来源:try_lock_until_pass.cpp

示例7: registerListener

	void StatisticsMultiplexerSync::registerListener( StatisticsMultiplexerListener * listener ) throw() {
		listenersLock.lock();
		for( size_t i = listeners.size(); i--; ) if( listeners[i].listener == listener ) goto doUnlock;
		listeners.emplace_back( listener );
		if( lastStatistics != nullptr ){
			listener->notifyAvailableStatisticsChange( *lastStatistics, true, false );
		}
	doUnlock:
		listenersLock.unlock();
	}
开发者ID:JulianKunkel,项目名称:siox,代码行数:10,代码来源:StatisticsMultiplexerSync.cpp

示例8: main

int main()
{
  m.lock();
  boost::thread t(f);
  boost::this_thread::sleep_for(ms(250));
  m.unlock();
  t.join();

  return boost::report_errors();
}
开发者ID:manctl,项目名称:boost,代码行数:10,代码来源:lock_pass.cpp

示例9: main

int main()
{
  m.lock();
  boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
  boost::this_thread::sleep_for(ms(250));
#else
#endif
  m.unlock();
  t.join();

  return boost::report_errors();
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:13,代码来源:try_lock_pass.cpp

示例10: thread3_func_workaround

void thread3_func_workaround()
{
  while (true)
  {
    if (mutex.timed_lock_shared(boost::posix_time::milliseconds(200)))
    {
      std::cout << "Shared lock acquired" << std::endl
        << "Test successful" << std::endl;
      mutex.unlock_shared();
      break;
    }
    boost::this_thread::sleep(boost::posix_time::milliseconds(100));
  }
}
开发者ID:AlexMioMio,项目名称:boost,代码行数:14,代码来源:test_7755.cpp

示例11: Finished

bool TransferInfo::Finished() {
  checkbook_mutex_.lock_shared();
  bool finished = true;
  for (int i = 0; i < checkbook_->slice_size(); ++i) {
    VLOG(4) << i << " checkbook slice: " << checkbook_->slice(i).finished();
    if (!checkbook_->slice(i).finished()) {
      finished = false;
      VLOG(1) << "slice: " << i << " unfinished";
      checkbook_mutex_.unlock_shared();
      return false;
    }
  }
  checkbook_mutex_.unlock_shared();
  return true;
}
开发者ID:0xec,项目名称:server1,代码行数:15,代码来源:file_transfer_service.cpp

示例12: addTrack

int TrackManager::addTrack( const string pFileName, CTrackInfo & pTrackData)
{
	mySharedMutex.lock();
	MP3Data * currentMP3Data = myController->addMP3( pFileName.c_str());
	int id = currentMP3Data->getId();
	if( id != INVALID_INDEX)
	{
		pTrackData.mIndex = currentMP3Data->getId();
		pTrackData.mAlbum = currentMP3Data->getAlbum();
		pTrackData.mInterpret = currentMP3Data->getArtist();
		pTrackData.mTitle = currentMP3Data->getTitle();
	}
	myController->createIndex();
	mySharedMutex.unlock();	
	return id;
}
开发者ID:johnjohndoe,项目名称:Programming,代码行数:16,代码来源:TrackManager.cpp

示例13: f

void f()
{
#if defined BOOST_THREAD_USES_CHRONO
  t0 = Clock::now();
  m.lock();
  t1 = Clock::now();
  m.unlock();
#else
  //time_point t0 = Clock::now();
  m.lock();
  //time_point t1 = Clock::now();
  m.unlock();
  //ns d = t1 - t0 - ms(250);
  //BOOST_TEST(d < max_diff);
#endif
}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:16,代码来源:lock_pass.cpp

示例14: f2

void f2()
{
  time_point t0 = Clock::now();
  BOOST_TEST(m.try_lock_for(ms(250)) == false);
  time_point t1 = Clock::now();
  ns d = t1 - t0 - ms(250);
  // This test is spurious as it depends on the time the thread system switches the threads
  BOOST_TEST(d < ns(5000000)+ms(1000)); // within 5ms
}
开发者ID:karelp,项目名称:openlierox-win-build,代码行数:9,代码来源:try_lock_for_pass.cpp

示例15: f

void f()
{
#if defined BOOST_THREAD_USES_CHRONO
  time_point t0 = Clock::now();
  m.lock();
  time_point t1 = Clock::now();
  m.unlock();
  ns d = t1 - t0 - ms(250);
  // This test is spurious as it depends on the time the thread system switches the threads
  BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
#else
  //time_point t0 = Clock::now();
  m.lock();
  //time_point t1 = Clock::now();
  m.unlock();
  //ns d = t1 - t0 - ms(250);
  // This test is spurious as it depends on the time the thread system switches the threads
  //BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms
#endif
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:20,代码来源:lock_pass.cpp


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