Esempio n. 1
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;
}