コード例 #1
0
ファイル: threadpsx.cpp プロジェクト: czxxjtu/wxPython-1
wxSemaError wxSemaphoreInternal::Wait()
{
    wxMutexLocker locker(m_mutex);

    while ( m_count == 0 )
    {
        wxLogTrace(TRACE_SEMA,
                   _T("Thread %ld waiting for semaphore to become signalled"),
                   wxThread::GetCurrentId());

        if ( m_cond.Wait() != wxCOND_NO_ERROR )
            return wxSEMA_MISC_ERROR;

        wxLogTrace(TRACE_SEMA,
                   _T("Thread %ld finished waiting for semaphore, count = %lu"),
                   wxThread::GetCurrentId(), (unsigned long)m_count);
    }

    m_count--;

    return wxSEMA_NO_ERROR;
}
コード例 #2
0
void* SearchThread::Entry() {
    while (1) {
        // Wait for signal that we should start search
        m_isWaiting = true;
        wxMutexLocker lock(m_condMutex);
        m_startSearchCond.Wait();
        m_isWaiting = false;

        if (m_stopSearch) {
            while (1) {
                if (TestDestroy()) break;
                Sleep(100);
            }
        }

        SearchInfo si;
        if (!PrepareSearchInfo(si, m_pattern, m_matchCase, m_regex)) continue;

        m_isSearching = true;

        ProjectInfoHandler infoHandler;
        infoHandler.SetRoot(m_path);

        // Write the html header for output
        m_outputCrit.Enter();
        m_output = wxT("<head><style type=\"text/css\">#match {background-color: yellow}</style></head>");
        m_outputCrit.Leave();

        SearchDir(m_path, si, infoHandler);
        m_isSearching = false;

        // Clean up
        if (si.regex) free(si.regex);
    }

    return NULL;
}