示例#1
0
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
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
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
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;
            }
        }
    }
}