Esempio n. 1
0
	void CachePaths()
	{
		std::lock_guard<std::mutex> lock1(CachedResourcesPathMutex);
		std::lock_guard<std::mutex> lock2(CachedDocumentsPathMutex);
		std::lock_guard<std::mutex> lock3(CachedWritablePathMutex);

		CachedResourcesPath = GetPureResourcesPath();
		CachedDocumentsPath = GetPureDocumentsPath();
		CachedWritablePath = GetPureWritablePath();
	}
Esempio n. 2
0
void Settings::update(const Settings &other)
{
	if (&other == this)
		return;

	JMutexAutoLock lock(m_mutex);
	JMutexAutoLock lock2(other.m_mutex);

	updateNoLock(other);
}
int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop, int timeout)
{
  CSingleLock lock2(m_presentlock);

  // check if gui is active and discard buffer if not
  // this keeps videoplayer going
  if (!m_bRenderGUI || !g_application.GetRenderGUI())
  {
    m_bRenderGUI = false;
    double presenttime = 0;
    double clock = GetPresentTime();
    if (!m_queued.empty())
    {
      int idx = m_queued.front();
      presenttime = m_Queue[idx].timestamp;
    }
    else
      presenttime = clock + 0.02;

    int sleeptime = (presenttime - clock) * 1000;
    if (sleeptime < 0)
      sleeptime = 0;
    sleeptime = std::min(sleeptime, 20);
    m_presentevent.wait(lock2, sleeptime);
    DiscardBuffer();
    return 0;
  }

  XbmcThreads::EndTime endtime(timeout);
  while(m_free.empty())
  {
    m_presentevent.wait(lock2, std::min(50, timeout));
    if(endtime.IsTimePast() || bStop)
    {
      if (timeout != 0 && !bStop)
      {
        CLog::Log(LOGWARNING, "CRenderManager::WaitForBuffer - timeout waiting for buffer");
        m_waitForBufferCount++;
        if (m_waitForBufferCount > 2)
        {
          m_bRenderGUI = false;
        }
      }
      return -1;
    }
  }

  m_waitForBufferCount = 0;

  // make sure overlay buffer is released, this won't happen on AddOverlay
  m_overlays.Release(m_free.front());

  // return buffer level
  return m_queued.size() + m_discard.size();;
}
void CFunctionProfiler::FunctionEnter2(
    /*[in]*/FunctionID                          funcID, 
    /*[in]*/UINT_PTR                            clientData, 
    /*[in]*/COR_PRF_FRAME_INFO                  func, 
    /*[in]*/COR_PRF_FUNCTION_ARGUMENT_INFO      *argumentInfo)
{
    ThreadID threadId;
    m_profilerInfo2->GetCurrentThreadID(&threadId);
    DWORD windowThreadId;
    m_profilerInfo2->GetThreadInfo(threadId, &windowThreadId);

    CComCritSecLock<CComAutoCriticalSection> lock(m_cs);
    FunctionInfo & fi = m_functions[clientData];
    if (!fi.trace) return;

    if (!fi.assigned)
    {
        fi.assigned = true;
        std::wstring szMethodName;
        GetMetadataFullMethodName(funcID, func, szMethodName);
        bool temp;
        if (!Include(szMethodName, &temp)) {fi.trace=false; return; }                                                           
        GetMetadataFullMethodNameWithSignature(funcID, func, fi.metadataSignature);
    }
    std::wstring runtimeSignature;
    GetRuntimeFullMethodSignature(funcID, func, runtimeSignature);
    
    CScopedLock<CMutex> lock2(m_hProcessMutex);
    m_currentBuffer = m_formatBuffer + (*((DWORD*)m_pView));

    BYTE type = 1;
    double elapsed = m_timer.Elapsed();

    Write(type);
    Write(m_sequence);
    Write(elapsed);
    Write(windowThreadId);
    Write<ULONGLONG>(funcID);

    m_sequence++;

    DWORD len1 = (DWORD)runtimeSignature.length();
    Write(len1);

    memcpy(m_currentBuffer, runtimeSignature.c_str(), len1 * 2);
    m_currentBuffer += (len1 * 2);

    DWORD len2 = (DWORD)fi.metadataSignature.length();
    Write(len2);

    memcpy(m_currentBuffer, fi.metadataSignature.c_str(), len2 * 2);
    m_currentBuffer += (len2 * 2);
    
    WriteData();
}
void ossimPlanetClientConnection::sendNextMessage()
{
   OpenThreads::ScopedLock<OpenThreads::Mutex> lock1(theMessageQueueMutex);
   OpenThreads::ScopedLock<OpenThreads::Mutex> lock2(theMutex);

   if(!theMessageQueue.empty()&&theSocket)
   {
      ossimString message = popMessage();
      theSocket->writestring(message.c_str());
   }
}
void thread1()
{
    std::lock_guard<std::mutex> lock1(mutex1);

    // Simulate some non-trivial execution.
    std::this_thread::sleep_for(std::chrono::milliseconds(2000));
    
    std::lock_guard<std::mutex> lock2(mutex2);

    std::cout << "thread 1\n";
}
Esempio n. 7
0
	void Master::removeClient(std::uint64_t clientId)
	{
		{
			std::lock_guard<std::recursive_mutex> lock(clientsMutex);
			clients.erase(clientId);
		}
		{
			std::lock_guard<std::recursive_mutex> lock2(listenersMutex);
			for (auto *l: listeners) l->clientDisconnected(clientId);
		}
	}
Esempio n. 8
0
  void RetardedAsynchCallbackHandler::makePendingCalls()
  {
    TRACE;
    CSingleLock lock(critSection);
    CallbackQueue::iterator iter = g_callQueue.begin();
    while (iter != g_callQueue.end())
    {
      AddonClass::Ref<AsynchCallbackMessage> p(*iter);

      // only call when we are in the right thread state
      if(p->handler->isThreadStateOk())
      {
        // remove it from the queue. No matter what we're done with
        //  this. Even if it doesn't execute for some reason.
        g_callQueue.erase(iter);

        // we need to release the critSection lock prior to grabbing the
        //  lock on the object. Not doing so results in deadlocks. We no
        //  longer are accessing the g_callQueue so it's fine to do this now
        {
          XBMCAddonUtils::InvertSingleLockGuard unlock(lock);

          // make sure the object is not deallocating

          // we need to grab the object lock to see if the object of the call 
          //  is deallocating. holding this lock should prevent it from 
          //  deallocating durring the execution of this call.
          CLog::Log(LOGDEBUG,"NEWADDON executing callback 0x%lx", (long)(p->cb.get()));
          Synchronize lock2(*(p->cb->getObject()));
          if (!p->cb->getObject()->isDeallocating())
          {
            try
            {
              // need to make the call
              p->cb->executeCallback();
            }
            catch (XbmcCommons::Exception& e) { e.LogThrowMessage(); }
            catch (...)
            {
              CLog::Log(LOGERROR,"Unknown exception while executeing callback 0x%lx", (long)(p->cb.get()));
            }
          }
        }

        // since the state of the iterator may have been corrupted by
        //  the changing state of the list from another thread durring
        //  the releasing fo the lock in the immediately preceeding 
        //  codeblock, we need to reset it before continuing the loop
        iter = g_callQueue.begin();
      }
      else // if we're not in the right thread for this callback...
        iter++;
    }  
  }
Esempio n. 9
0
 float KeyFrame::ComputeSceneMedianDepthWithCoord(int &x, int &y, int q) {
     
     //vector<MapPoint*> vpMapPoints;
     cv::Mat Tcw_;
     {
         boost::mutex::scoped_lock lock(mMutexFeatures);
         boost::mutex::scoped_lock lock2(mMutexPose);
         //vpMapPoints = mvpMapPoints;
         Tcw_ = Tcw.clone();
     }
     
     vector<float> vDepths;
     vDepths.reserve(mvpMapPoints.size());
     cv::Mat Rcw2 = Tcw_.row(2).colRange(0,3);
     Rcw2 = Rcw2.t();
     float zcw = Tcw_.at<float>(2,3);
     for(size_t i=0; i<mvpMapPoints.size(); i++)
     {
         if(mvpMapPoints[i])
         {
             MapPoint* pMP = mvpMapPoints[i];
             cv::Mat x3Dw = pMP->GetWorldPos();
             float z = Rcw2.dot(x3Dw)+zcw;
             vDepths.push_back(z);
         }
     }
     
     vector<size_t> depthIndex(vDepths.size());
     for (size_t i = 0; i != depthIndex.size(); ++i) depthIndex[i] = i;
     
     sort(vDepths.begin(),vDepths.end());
     sort(depthIndex.begin(), depthIndex.end(),
          [&vDepths](size_t i1, size_t i2) {return vDepths[i1] < vDepths[i2];});
     
     size_t medianIndex = depthIndex[(vDepths.size()-1)/q];
     size_t ptCounter = 0;
     MapPoint* pointWithMedianDepth;
     for (size_t i = 0; i<mvpMapPoints.size(); i++) {
         if (mvpMapPoints[i]) {
             if (ptCounter == medianIndex) {
                 pointWithMedianDepth = mvpMapPoints[i];
                 break;
             }
             ptCounter++;
         }
     }
     if (pointWithMedianDepth) {
         size_t keysUnIdx = pointWithMedianDepth->GetIndexInKeyFrame(this);
         x = mvKeysUn[keysUnIdx].pt.x;
         y = mvKeysUn[keysUnIdx].pt.y;
     }
     
     return vDepths[(vDepths.size()-1)/q];
 }
Esempio n. 10
0
//---------------------------------------------------------------------------
LogFile & LogFile::flush(bool wait)
{
  uint64_t ft = 0;
  {
    AutoLock<LiteWriteLock> lock2(threadReadWriteLock_);
    if( bufferPos_ > 0 ){
      bufferSemaphore_.post();
      ft = lastFlushTime_;
    }
    else {
      wait = false;
    }
  }
  while( wait ){
    AutoLock<LiteWriteLock> lock2(threadReadWriteLock_);
    if( ft != lastFlushTime_ ) break;
    ksleep1();
  }
  return *this;
}
Esempio n. 11
0
double LanguageModel::kullbackLeiblerDivergence(LanguageModel *p, LanguageModel *q) {
	LocalLock lock1(p);
	LocalLock lock2(q);
	double result = 0.0;
	for (int i = 0; i < p->termSlotsUsed; i++) {
		double pX = p->terms[i].termFrequency / p->corpusSize;
		double qX = q->getTermProbability(p->terms[i].term);
		result += kullbackLeiblerDivergence(pX, qX, q->corpusSize);
	}
	return result;
} // end of kullbackLeiblerDivergence(LanguageModel*, LanguageModel*)
Esempio n. 12
0
STDMETHODIMP TffdshowVideoInputPin::EndOfStream()
{
    CAutoLock lock1((CCritSec*)fv->deci->get_csReceive_ptr());
    CAutoLock lock2(&m_csCodecs_and_imgFilters);
    if (m_rateAndFlush.m_flushing) {
        return S_OK;
    }
    m_rateAndFlush.m_endflush = false;
    video->onEndOfStream();
    return TinputPin::EndOfStream();
}
SWDecoder const &SWDecoder::operator= (SWDecoder const &rhs)
{
	if(&rhs != this)
	{
		/* but here we need to lock both */
		boost::lock_guard<boost::mutex> lock1(&mMutex < &rhs.mMutex ? mMutex : rhs.mMutex);
		boost::lock_guard<boost::mutex> lock2(&mMutex > &rhs.mMutex ? mMutex : rhs.mMutex);
		mFinish = rhs.mFinish;
		mState  = rhs.mState;
	}
	return *this;
}
void ossimPlanetTextureLayerGroup::resetStats()const
{
   OpenThreads::ScopedLock<OpenThreads::Mutex> lock2(theChildrenListMutex);
   ossim_uint32 idx;
   theStats->setBytesTransferred(0);
   theStats->setTotalTextureSize(0);
   for(idx = 0; idx < theChildrenList.size(); ++idx)
   {
      osg::ref_ptr<ossimPlanetTextureLayer::Stats> stats = theChildrenList[idx]->getStats();
      theStats->setTotalTextureSize(theStats->totalTextureSize() + stats->totalTextureSize());
   }
}
void ArpListener::stop()
{
  MutexLocker lock( runningMutex_ );
  if( !running_ )
    return;
  MutexLocker lock2( stopMutex_ );
  stop_ = true;
  lock2.unlock();
  sniffer_.stop();
  listenerThread_.join();
  running_ = false;
}
Esempio n. 16
0
int main()
{
    boost::detail::lightweight_mutex::scoped_lock lock1( m1 );

    boost::detail::lightweight_mutex m2;
    boost::detail::lightweight_mutex m3;

    boost::detail::lightweight_mutex::scoped_lock lock2( m2 );
    boost::detail::lightweight_mutex::scoped_lock lock3( m3 );

    return 0;
}
Esempio n. 17
0
bool CGitIgnoreList::CheckAndUpdateCoreExcludefile(const CString &adminDir)
{
	CString projectConfig = adminDir + _T("config");
	CString globalConfig = g_Git.GetGitGlobalConfig();
	CString globalXDGConfig = g_Git.GetGitGlobalXDGConfig();

	CAutoWriteLock lock(m_coreExcludefilesSharedMutex);
	bool hasChanged = CheckAndUpdateGitSystemConfigPath();
	hasChanged = hasChanged || CheckFileChanged(projectConfig);
	hasChanged = hasChanged || CheckFileChanged(globalConfig);
	hasChanged = hasChanged || CheckFileChanged(globalXDGConfig);
	if (!m_sGitSystemConfigPath.IsEmpty())
		hasChanged = hasChanged || CheckFileChanged(m_sGitSystemConfigPath);

	CString excludesFile;
	{
		CAutoReadLock lock2(m_SharedMutex);
		excludesFile = m_CoreExcludesfiles[adminDir];
	}
	if (!excludesFile.IsEmpty())
		hasChanged = hasChanged || CheckFileChanged(excludesFile);

	if (!hasChanged)
		return false;

	CAutoConfig config(true);
	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(projectConfig), GIT_CONFIG_LEVEL_LOCAL, FALSE);
	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalConfig), GIT_CONFIG_LEVEL_GLOBAL, FALSE);
	git_config_add_file_ondisk(config, CGit::GetGitPathStringA(globalXDGConfig), GIT_CONFIG_LEVEL_XDG, FALSE);
	if (!m_sGitSystemConfigPath.IsEmpty())
		git_config_add_file_ondisk(config, CGit::GetGitPathStringA(m_sGitSystemConfigPath), GIT_CONFIG_LEVEL_SYSTEM, FALSE);
	config.GetString(_T("core.excludesfile"), excludesFile);
	if (excludesFile.IsEmpty())
		excludesFile = GetWindowsHome() + _T("\\.config\\git\\ignore");
	else if (excludesFile.Find(_T("~/")) == 0)
		excludesFile = GetWindowsHome() + excludesFile.Mid(1);

	CAutoWriteLock lockMap(m_SharedMutex);
	g_Git.GetFileModifyTime(projectConfig, &m_Map[projectConfig].m_LastModifyTime);
	g_Git.GetFileModifyTime(globalXDGConfig, &m_Map[globalXDGConfig].m_LastModifyTime);
	if (m_Map[globalXDGConfig].m_LastModifyTime == 0)
		m_Map.erase(globalXDGConfig);
	g_Git.GetFileModifyTime(globalConfig, &m_Map[globalConfig].m_LastModifyTime);
	if (m_Map[globalConfig].m_LastModifyTime == 0)
		m_Map.erase(globalConfig);
	if (!m_sGitSystemConfigPath.IsEmpty())
		g_Git.GetFileModifyTime(m_sGitSystemConfigPath, &m_Map[m_sGitSystemConfigPath].m_LastModifyTime);
	if (m_Map[m_sGitSystemConfigPath].m_LastModifyTime == 0 || m_sGitSystemConfigPath.IsEmpty())
		m_Map.erase(m_sGitSystemConfigPath);
	m_CoreExcludesfiles[adminDir] = excludesFile;

	return true;
}
Esempio n. 18
0
STDMETHODIMP TffdshowVideoInputPin::Receive(IMediaSample* pSample)
{
    AM_MEDIA_TYPE *pmt = NULL;
    if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
        CAutoLock lock2(&m_csCodecs_and_imgFilters);
        CMediaType mt(*pmt);
        SetMediaType(&mt);
        allocator.mtChanged = false;
        DeleteMediaType(pmt);
    }
    return TinputPin::Receive(pSample);
}
Esempio n. 19
0
void CXBMCRenderManager::DiscardBuffer()
{
  CSharedLock lock(m_sharedSection);
  CSingleLock lock2(m_presentlock);

  while(!m_queued.empty())
    requeue(m_discard, m_queued);

  if(m_presentstep == PRESENT_READY)
    m_presentstep   = PRESENT_IDLE;
  m_presentevent.notifyAll();
}
Esempio n. 20
0
void OperThreadWin::DBGPrintStoppingList()
{
	MutexLock lock1( &operMutex );

	OperThreadNode* p;

	for ( p = operStopList; p; p = p->next )
	{
		MutexLock lock2( &p->mutex );
		printf( "stopped thread %s\n", p->threadInfo.data() ? p->threadInfo.data() : "<empty info>" );
	}
}
Esempio n. 21
0
void CTimeShiftUtil::GetFilePos(__int64* filePos, __int64* fileSize)
{
	CBlockLock lock(&this->utilLock);
	CBlockLock lock2(&this->ioLock);

	if( filePos != NULL ){
		*filePos = this->currentFilePos;
	}
	if( fileSize != NULL ){
		*fileSize = GetAvailableFileSize();
	}
}
Esempio n. 22
0
    void Master::addVersion(const std::string &name)
    {
        std::lock_guard<std::recursive_mutex> lock(versionsMutex);

        MasterVersion ver;
        ver.name = name;
        ver.throttle = 0.0;
        versions[name] = ver;

        std::lock_guard<std::recursive_mutex> lock2(listenersMutex);
        for (auto *l: listeners) l->versionAdded(*this, name);
    }
Esempio n. 23
0
	void Editor::update()
	{
		sh::Factory::getInstance().doMonitorShaderFiles();

		if (!mMainWindow)
			return;


		{
			boost::mutex::scoped_lock lock(mSync.mActionMutex);

			// execute pending actions
			while (mMainWindow->mActionQueue.size())
			{
				Action* action = mMainWindow->mActionQueue.front();
				action->execute();
				delete action;
				mMainWindow->mActionQueue.pop();
			}
		}
		{
			boost::mutex::scoped_lock lock(mSync.mQueryMutex);

			// execute pending queries
			for (std::vector<Query*>::iterator it = mMainWindow->mQueries.begin(); it != mMainWindow->mQueries.end(); ++it)
			{
				Query* query = *it;
				if (!query->mDone)
					query->execute();
			}
		}

		boost::mutex::scoped_lock lock2(mSync.mUpdateMutex);

		// update the list of materials
		mMainWindow->mState.mMaterialList.clear();
		sh::Factory::getInstance().listMaterials(mMainWindow->mState.mMaterialList);

		// update global settings
		mMainWindow->mState.mGlobalSettingsMap.clear();
		sh::Factory::getInstance().listGlobalSettings(mMainWindow->mState.mGlobalSettingsMap);

		// update configuration list
		mMainWindow->mState.mConfigurationList.clear();
		sh::Factory::getInstance().listConfigurationNames(mMainWindow->mState.mConfigurationList);

		// update shader list
		mMainWindow->mState.mShaderSets.clear();
		sh::Factory::getInstance().listShaderSets(mMainWindow->mState.mShaderSets);

		mMainWindow->mState.mErrors += sh::Factory::getInstance().getErrorLog();
	}
Esempio n. 24
0
// Unmount a file system returning the number of open files were invalidated
unsigned int MassStorage::InternalUnmount(size_t card, bool doClose)
{
	SdCardInfo& inf = info[card];
	MutexLocker lock1(fsMutex);
	MutexLocker lock2(inf.volMutex);
	const unsigned int invalidated = InvalidateFiles(&inf.fileSystem, doClose);
	const char path[3] = { (char)('0' + card), ':', 0 };
	f_mount(nullptr, path, 0);
	memset(&inf.fileSystem, 0, sizeof(inf.fileSystem));
	sd_mmc_unmount(card);
	inf.isMounted = false;
	return invalidated;
}
Esempio n. 25
0
Settings & Settings::operator = (const Settings &other)
{
	if (&other == this)
		return *this;

	MutexAutoLock lock(m_mutex);
	MutexAutoLock lock2(other.m_mutex);

	clearNoLock();
	updateNoLock(other);

	return *this;
}
Esempio n. 26
0
void CXBMCRenderManager::FrameMove()
{
  { CSharedLock lock(m_sharedSection);
    CSingleLock lock2(m_presentlock);

    if (!m_pRenderer)
      return;

    if (m_presentstep == PRESENT_FRAME2)
    {
      if(!m_queued.empty())
      {
        double timestamp = GetPresentTime();
        SPresent& m = m_Queue[m_presentsource];
        SPresent& q = m_Queue[m_queued.front()];
        if(timestamp > m.timestamp + (q.timestamp - m.timestamp) * 0.5)
        {
          m_presentstep = PRESENT_READY;
          m_presentevent.notifyAll();
        }
      }
    }

    if (m_presentstep == PRESENT_READY)
      PrepareNextRender();

    if(m_presentstep == PRESENT_FLIP)
    {
      m_pRenderer->FlipPage(m_presentsource);
      m_presentstep = PRESENT_FRAME;
      m_presentevent.notifyAll();
    }

    /* release all previous */
    for(std::deque<int>::iterator it = m_discard.begin(); it != m_discard.end(); )
    {
      // renderer may want to keep the frame for postprocessing
      if (!m_pRenderer->NeedBufferForRef(*it) || !m_bRenderGUI)
      {
        m_pRenderer->ReleaseBuffer(*it);
        m_overlays.Release(*it);
        m_free.push_back(*it);
        it = m_discard.erase(it);
      }
      else
        ++it;
    }

    m_bRenderGUI = true;
  }
}
Esempio n. 27
0
bool CGUIDialogKaiToast::DoWork()
{
  CSingleLock lock(m_critical);

  if (!m_notifications.empty() &&
      CTimeUtils::GetFrameTime() - m_timer > m_toastMessageTime)
  {
    Notification toast = m_notifications.front();
    m_notifications.pop();
    lock.Leave();

    m_toastDisplayTime = toast.displayTime;
    m_toastMessageTime = toast.messageTime;

    CSingleLock lock2(g_graphicsContext);

    if(!Initialize())
      return false;

    SET_CONTROL_LABEL(POPUP_CAPTION_TEXT, toast.caption);

    SET_CONTROL_LABEL(POPUP_NOTIFICATION_BUTTON, toast.description);

    // set the appropriate icon
    {
      std::string icon = toast.imagefile;
      if (icon.empty())
      {
        if (toast.eType == Warning)
          icon = "DefaultIconWarning.png";
        else if (toast.eType == Error)
          icon = "DefaultIconError.png";
        else
          icon = "DefaultIconInfo.png";
      }
      SET_CONTROL_FILENAME(POPUP_ICON, icon);
    }

    //  Play the window specific init sound for each notification queued
    SetSound(toast.withSound);

    // Activate haptics for this notification
    CServiceBroker::GetPeripherals().OnUserNotification();

    ResetTimer();
    return true;
  }

  return false;
}
Esempio n. 28
0
void EmuTCPConnection::ClearBuffers() {
	TCPConnection::ClearBuffers();

	LockMutex lock2(&MOutQueueLock);
	ServerPacket* pack = 0;
	while ((pack = OutQueue.pop()))
		safe_delete(pack);

	EmuTCPNetPacket_Struct* tnps = 0;
	while ((tnps = InModeQueue.pop()))
		safe_delete(tnps);

	keepalive_timer.Start();
	timeout_timer.Start();
}
Esempio n. 29
0
 LFXE_API bool Device::CommitQueuedTimeline(const bool flushQueue) {
     if (this->isEnabled) {
         // Place the pre-queued item into the queue
         lock_guard<mutex> lock(this->TimelineQueueMutex);
         if (flushQueue) {
             this->TimelineQueue = {};
             this->timelineDone = true;
         }
         lock_guard<mutex> lock2(this->QueuedTimelineMutex);
         this->TimelineQueue.push(this->QueuedTimeline);
         this->QueuedTimeline = {};
         return true;
     }
     return false;
 }
Esempio n. 30
0
//--------------------------------------------------------------------------------
int CThreadPool::GetPoolSize()
	{
	CSingleLock lock(&m_waiting.m_mutex, false);
	if(! lock.Lock(10000))
		return -1;

	CSingleLock lock2(&m_active.m_mutex, false);
	if(! lock2.Lock(10000))
		return -1;

#ifdef _DEBUG
	TRACE(_T("waiting = %d active = %d\n"), m_waiting.GetCount(), m_active.GetCount());
#endif
	return m_waiting.GetCount() + m_active.GetCount();
	}