Пример #1
0
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
}
Пример #2
0
bool TrackManager::removeTrack( int pIndex)
{
	mySharedMutex.lock();
	bool isRemoved = myController->getTrackList()->removeObjById( pIndex);
	myController->createIndex();
	mySharedMutex.unlock();
	return isRemoved;
}
	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();
	}
Пример #4
0
int main()
{
  m.lock();
  boost::thread t(f);
  boost::this_thread::sleep_for(ms(250));
  m.unlock();
  t.join();

  return boost::report_errors();
}
	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();
	}
Пример #6
0
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
}
Пример #7
0
 void get ()
 {
    try
    {
       _m.lock() ;
    }
    catch(...)
    {
       SDB_ASSERT ( FALSE, "SLatch get failed" ) ;
    }
 }
Пример #8
0
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();
}
Пример #9
0
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;
}
Пример #10
0
int TrackManager::trackSearchStart( const string & pTitleBeginn, TSearchID & pID)
{
	if( pTitleBeginn == "")
	{
		myController->getTrackList()->begin();
		pID = ALL_TRACKS_SEARCH_ID;
		return myController->getTrackList()->getLength();
	}
	else
	{
		mySharedMutex.lock();
		searchResultCount++;
		searchResultList[searchResultCount] = myController->getSearchResult( pTitleBeginn.c_str());
		pID = searchResultCount;
		std::cout << "search started, searchID: " << pID << std::endl;
		unsigned int length = searchResultList[searchResultCount]->getLength();
		mySharedMutex.unlock();
		return length;
	}
}
Пример #11
0
int main()
{
  m.lock();
  boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
  time_point t2 = Clock::now();
  boost::this_thread::sleep_for(ms(250));
  time_point t3 = Clock::now();
#else
#endif
  m.unlock();
  t.join();

#if defined BOOST_THREAD_USES_CHRONO
  ns sleep_time = t3 - t2;
  ns d_ns = t1 - t0 - sleep_time;
  ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns);
  // BOOST_TEST_GE(d_ms.count(), 0);
  BOOST_THREAD_TEST_IT(d_ms, max_diff);
  BOOST_THREAD_TEST_IT(d_ns, ns(max_diff));
#endif

  return boost::report_errors();
}