Ejemplo n.º 1
0
bool DummyStorageLink::onDown(const api::StorageMessage::SP& cmd)
{
    if (_ignore) {
        return false;
    }
    if (_injected.size() > 0) {
        vespalib::LockGuard guard(_lock);
        sendUp(*_injected.begin());
        _injected.pop_front();
    } else if (_autoReply) {
        if (!cmd->getType().isReply()) {
            std::shared_ptr<api::StorageReply> reply(
                    std::dynamic_pointer_cast<api::StorageCommand>(cmd)
                    ->makeReply().release());
            reply->setResult(api::ReturnCode(
                    api::ReturnCode::OK, "Automatically generated reply"));
            sendUp(reply);
        }
    }
    if (isBottom()) {
        vespalib::MonitorGuard lock(_waitMonitor);
        {
            vespalib::LockGuard guard(_lock);
            _commands.push_back(cmd);
        }
        lock.broadcast();
        return true;
    }
    return StorageLink::onDown(cmd);
}
Ejemplo n.º 2
0
Pointer &
Pointer::meet(const Domain &value)
{
    if (isBottom())
        return *this;

    if (value.isTop())
        return *this;

    if (value.isBottom())
    {
        setBottom();
        return *this;
    }

    const Pointer &vv = llvm::cast<Pointer>(value);
    CANAL_ASSERT_MSG(&vv.mType == &mType,
                     "Unexpected different types in a pointer merge ("
                     << Canal::toString(vv.mType) << " != "
                     << Canal::toString(mType) << ")");

    if (isTop())
    {
        mTop = false;
        CANAL_ASSERT(mTargets.empty());
    }

    PlaceTargetMap::iterator it = mTargets.begin();
    for (; it != mTargets.end(); ++it)
    {
        PlaceTargetMap::const_iterator valueit = vv.mTargets.find(it->first);
        if (it == vv.mTargets.end())
        {
            delete it->second;
            mTargets.erase(it);
        }
        else
            it->second->meet(*valueit->second);
    }

    return *this;
}