예제 #1
0
int ParserThreadedTask::Execute()
{
    TRACE(_T("ParserThreadedTask::Execute(): Enter"));
    if (!m_Parser) return 0;

    CC_LOCKER_TRACK_P_MTX_LOCK(m_ParserMutex)

    wxString   preDefs(m_Parser->m_PredefinedMacros);

    StringList batchFiles(m_Parser->m_BatchParseFiles);

    CC_LOCKER_TRACK_P_MTX_UNLOCK(m_ParserMutex);

    TRACE(_T("ParserThreadedTask::Execute(): Parse predefined macros(in buffer)"));
    if (!preDefs.IsEmpty())
        m_Parser->ParseBuffer(preDefs, false, false);

    CC_LOCKER_TRACK_P_MTX_LOCK(m_ParserMutex)

    m_Parser->m_PredefinedMacros.Clear();

    CC_LOCKER_TRACK_P_MTX_UNLOCK(m_ParserMutex);

    if (m_Parser->m_IgnoreThreadEvents)
        m_Parser->m_IsFirstBatch = true;

    TRACE(_T("ParserThreadedTask::Execute(): Parse source files"));
    while (!batchFiles.empty())
    {
        TRACE(_T("-ParserThreadedTask::Execute(): Parse %s"), batchFiles.front().wx_str());
        m_Parser->Parse(batchFiles.front());
        batchFiles.pop_front();
    }

    CC_LOCKER_TRACK_P_MTX_LOCK(m_ParserMutex)

    m_Parser->m_BatchParseFiles.clear();

    if (m_Parser->m_IgnoreThreadEvents)
    {
        m_Parser->m_IgnoreThreadEvents = false; // we need to hear the pool finish event
        m_Parser->m_IsParsing = true;
    }

    CC_LOCKER_TRACK_P_MTX_UNLOCK(m_ParserMutex);
    TRACE(_T("ParserThreadedTask::Execute(): Leave"));

    return 0;
}
예제 #2
0
    int Execute()
    {
        TRACK_THREAD_LOCKER(s_ParserCritical);
        s_ParserCritical.Enter();
        THREAD_LOCKER_SUCCESS(s_ParserCritical);
        wxString preDefs(m_Parser.m_PredefinedMacros);
        StringList priorityHeaders(m_Parser.m_PriorityHeaders);
        StringList batchFiles(m_Parser.m_BatchParseFiles);
        s_ParserCritical.Leave();

        if (!preDefs.IsEmpty())
            m_Parser.ParseBuffer(preDefs, false, false);

        {
            TRACK_THREAD_LOCKER(s_ParserCritical);
            wxCriticalSectionLocker locker(s_ParserCritical);
            THREAD_LOCKER_SUCCESS(s_ParserCritical);

            m_Parser.m_PredefinedMacros.Clear();
            m_Parser.m_IsPriority = true;
        }

        while (!priorityHeaders.empty())
        {
            m_Parser.Parse(priorityHeaders.front());
            priorityHeaders.pop_front();
        }

        {
            TRACK_THREAD_LOCKER(s_ParserCritical);
            wxCriticalSectionLocker locker(s_ParserCritical);
            THREAD_LOCKER_SUCCESS(s_ParserCritical);

            m_Parser.m_PriorityHeaders.clear();
            m_Parser.m_IsPriority = false;

            if (m_Parser.m_IgnoreThreadEvents)
                m_Parser.m_IsFirstBatch = true;
        }

        while (!batchFiles.empty())
        {
            m_Parser.Parse(batchFiles.front());
            batchFiles.pop_front();
        }

        {
            TRACK_THREAD_LOCKER(s_ParserCritical);
            wxCriticalSectionLocker locker(s_ParserCritical);
            THREAD_LOCKER_SUCCESS(s_ParserCritical);

            m_Parser.m_BatchParseFiles.clear();

            if (m_Parser.m_IgnoreThreadEvents)
            {
                m_Parser.m_IgnoreThreadEvents = false;
                m_Parser.m_IsParsing = true;
            }
        }

        return 0;
    }