Пример #1
0
bool DataIStreamQueue::addDataPacket( const uint128_t& key, Command& command )
{
    EQ_TS_THREAD( _thread );
    EQASSERTINFO( _pending.size() < 100, "More than 100 pending commits");

    ObjectDataIStream* istream = 0;
    PendingStreams::iterator i = _pending.find( key );
    if( i == _pending.end( ))
        istream = _iStreamCache.alloc();
    else
        istream = i->second;

    istream->addDataPacket( command );
    if( istream->isReady( ))
    {
        if( i != _pending.end( ))
            _pending.erase( i );

        _queued.push( QueuedStream( key, istream ));
        EQASSERTINFO( _queued.getSize() < 100, "More than 100 queued commits" );
        //EQLOG( LOG_OBJECTS ) << "Queued commit " << key << std::endl;
        return true;
    }

    if( i == _pending.end( ))
    {
        _pending[ key ] = istream;
        //EQLOG( LOG_OBJECTS ) << "New incomplete commit " << key << std::endl;
        return false;
    }

    //EQLOG(LOG_OBJECTS) << "Add data to incomplete commit " << key <<std::endl;
    return false;
}
Пример #2
0
bool DataIStreamQueue::addDataCommand(const uint128_t& key, ICommand& command)
{
    LB_TS_THREAD(_thread);
    LBASSERTINFO(_pending.size() < 100, "More than 100 pending commits");

    ObjectDataIStream* is = 0;
    PendingStreams::iterator i = _pending.find(key);
    if (i == _pending.end())
        is = _iStreamCache.alloc();
    else
        is = i->second;

    is->addDataCommand(command);
    if (is->isReady())
    {
        if (i != _pending.end())
            _pending.erase(i);

        _queued.push(QueuedStream(key, is));
        return true;
    }

    if (i == _pending.end())
    {
        _pending[key] = is;
        return false;
    }

    return false;
}