コード例 #1
0
//=============================================================================
// METHOD     : SPELLcommandMailbox::push
//=============================================================================
void SPELLcommandMailbox::push( const ExecutorCommand cmd, const bool hp )
{
	if ((cmd.id == m_lastCommand)&&!isCommandRepeatable(cmd.id))
	{
		DEBUG("[CMD] Discarding repeated command: " + cmd.id);
		return;
	}
    if (hp)
    {
    	if (m_hqueue.size()==HQUEUE_MAX_SIZE)
    	{
    		DEBUG("[CM] Discarding command, hqueue full");
    		return;
    	}
    	else
    	{
            DEBUG("[CM] Pushing high priority command: " + cmd.id);
            m_hqueue.push(cmd);
    	}
    }
    else
    {
    	if (m_queue.size()==QUEUE_MAX_SIZE)
    	{
    		DEBUG("[CM] Discarding command, queue full");
    		return;
    	}
    	else
    	{
    		DEBUG("[CM] Pushing normal command: " + cmd.id);
    		m_queue.push(cmd);
    	}
    }
    m_lock.set();
}
コード例 #2
0
//=============================================================================
// METHOD     : SPELLcommandMailbox::pull
//=============================================================================
ExecutorCommand SPELLcommandMailbox::pull()
{
    ExecutorCommand cmd;
    bool gotten = false;
    while(!gotten)
    {
        DEBUG("[CM] Awaiting commands");
        m_lock.wait();
        if (!m_hqueue.empty())
        {
            cmd = m_hqueue.pull();
            if ((m_lastCommand != cmd.id)||isCommandRepeatable(cmd.id))
            {
                DEBUG("[CM] Got high priority command: " + cmd.id);
            	gotten = true;
            }
            else
            {
                DEBUG("[CM] Discarding high priority command: " + cmd.id);
            }
        }
        else if (!m_queue.empty())
        {
            cmd = m_queue.pull();
            if ((m_lastCommand != cmd.id)||isCommandRepeatable(cmd.id))
            {
                DEBUG("[CM] Got command: " + cmd.id);
            	gotten = true;
            }
            else
            {
                DEBUG("[CM] Discarding command: " + cmd.id);
            }
        }
        if (!gotten) m_lock.clear();
    }
    DEBUG("[CM] Pulled command: " + cmd.id);
    m_lastCommand = cmd.id;
    return cmd;
}
コード例 #3
0
ファイル: EshPathCommand.cpp プロジェクト: killbug2004/WSProf
ChEXPORT ChUINT2 EshPathCommand::encodeCount(
            EshPathCommandTypeEnums in_type, ChUINT2 in_unCookedCount)
{
    ChLOG_DEBUG_START_FN;
    ChASSERT((ChSINT4)in_type < (ChSINT4)ARRAYCOUNT(m_commandPropsArray));
    ChASSERT(m_commandPropsArray[in_type].m_type == in_type);

    ChASSERT(in_type < ESH_PATH_CMD_COUNT_OF_STORABLE);

    ChASSERT(in_unCookedCount > 0);
    ChASSERT(isCommandRepeatable(in_type) || in_unCookedCount == 1);
    
    const CommandProperties* pCommandProps = m_commandPropsArray + in_type;
    
    ChUINT2 unRawCount = (in_unCookedCount - pCommandProps->m_nOffset) 
                                            * pCommandProps->m_nScale;
    
    return unRawCount;
}