コード例 #1
0
ファイル: async_queue.cpp プロジェクト: mstorsjo/vlc
void AsyncQueue::flush()
{
    while (true)
    {
        vlc_mutex_lock( &m_lock );

        if( m_cmdList.size() > 0 )
        {
            // Pop the first command from the queue
            CmdGenericPtr cCommand = m_cmdList.front();
            m_cmdList.pop_front();

            // Unlock the mutex to avoid deadlocks if another thread wants to
            // enqueue/remove a command while this one is processed
            vlc_mutex_unlock( &m_lock );

            // Execute the command
            cCommand.get()->execute();
        }
        else
        {
            vlc_mutex_unlock( &m_lock );
            break;
        }
    }
}
コード例 #2
0
ファイル: async_queue.cpp プロジェクト: mstorsjo/vlc
void AsyncQueue::push( const CmdGenericPtr &rcCommand, bool removePrev )
{
    vlc_mutex_lock( &m_lock );

    if( removePrev )
    {
        // Remove the commands of the same type
        remove( rcCommand.get()->getType(), rcCommand );
    }
    m_cmdList.push_back( rcCommand );

    vlc_mutex_unlock( &m_lock );
}
コード例 #3
0
ファイル: async_queue.cpp プロジェクト: mstorsjo/vlc
void AsyncQueue::remove( const std::string &rType, const CmdGenericPtr &rcCommand )
{
    cmdList_t::iterator it;
    for( it = m_cmdList.begin(); it != m_cmdList.end(); /* nothing */ )
    {
        // Remove the command if it is of the given type and the command
        // doesn't disagree. Note trickery to avoid skipping entries
        // while maintaining iterator validity.

        if( (*it).get()->getType() == rType &&
            rcCommand.get()->checkRemove( (*it).get() ) )
        {
            cmdList_t::iterator itNew = it;
            ++itNew;
            m_cmdList.erase( it );
            it = itNew;
        }
        else ++it;
    }
}
コード例 #4
0
ファイル: async_queue.cpp プロジェクト: FLYKingdom/vlc
void AsyncQueue::remove( const string &rType, const CmdGenericPtr &rcCommand )
{
    list<CmdGenericPtr>::iterator it;
    for( it = m_cmdList.begin(); it != m_cmdList.end(); it++ )
    {
        // Remove the command if it is of the given type
        if( (*it).get()->getType() == rType )
        {
            // Maybe the command wants to check if it must really be
            // removed
            if( rcCommand.get()->checkRemove( (*it).get() ) == true )
            {
                list<CmdGenericPtr>::iterator itNew = it;
                itNew++;
                m_cmdList.erase( it );
                it = itNew;
            }
        }
    }
}