Exemplo n.º 1
0
bool TrackManager::trackGetNext( TSearchID pID, CTrackInfo & pNextTrack)
{
	MP3Data * t_Data = NULL;
	mySharedMutex.lock_shared();
	if(pID == ALL_TRACKS_SEARCH_ID) // Get whole track list
	{
		t_Data = myController->getTrackList()->getNext();
	
		if(t_Data != NULL)	// returns current iterator-item
		{
			pNextTrack.mAlbum = t_Data->getAlbum();
			pNextTrack.mInterpret = t_Data->getArtist();
			pNextTrack.mTitle = t_Data->getTitle();
			pNextTrack.mIndex = t_Data->getId();
			mySharedMutex.unlock_shared();
			return true;	// successfully retrieved item
		}
		else	// current iterator-item is NULL
		{
			mySharedMutex.unlock_shared();
			return false;
		}
	}
	else // get node list for the search-ID
	{	
		NodeList * t_searchResult = searchResultList[pID];

		if(t_searchResult)
		{
			t_Data = t_searchResult->getNext();

			if(t_Data != NULL) 
			{
				pNextTrack.mAlbum = t_Data->getAlbum();
				pNextTrack.mInterpret = t_Data->getArtist();
				pNextTrack.mTitle = t_Data->getTitle();
				pNextTrack.mIndex = t_Data->getId();
				mySharedMutex.unlock_shared();
				return true;
			}
			else
			{
				mySharedMutex.unlock_shared();
				return false;
			}
		}
		else
		{
			mySharedMutex.unlock_shared();
			return false;
		}

	}
}
Exemplo n.º 2
0
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;
}
	void StatisticsMultiplexerSync::newDataAvailable() throw() {
		listenersLock.lock_shared();
		for( size_t i = listeners.size(); i--; ) {
			ListenerData& cur = listeners[i];
			cur.listener->newDataAvailable();
		}
		listenersLock.unlock_shared();
	}
	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();
	}
Exemplo n.º 5
0
 void release_shared ()
 {
    try
    {
       _m.unlock_shared() ;
    }
    catch(...)
    {
       SDB_ASSERT ( FALSE, "SLatch release shared failed" ) ;
    }
 }
Exemplo n.º 6
0
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));
  }
}