Exemplo n.º 1
0
int zmq::msg_t::copy (msg_t &src_)
{
    //  Check the validity of the source.
    if (unlikely (!src_.check ())) {
        errno = EFAULT;
        return -1;
    }

    int rc = close ();
    if (unlikely (rc < 0))
        return rc;

    if (src_.u.base.type == type_lmsg) {

        //  One reference is added to shared messages. Non-shared messages
        //  are turned into shared messages and reference count is set to 2.
        if (src_.u.lmsg.flags & msg_t::shared)
            src_.u.lmsg.content->refcnt.add (1);
        else {
            src_.u.lmsg.flags |= msg_t::shared;
            src_.u.lmsg.content->refcnt.set (2);
        }
    }

    *this = src_;

    return 0;

}
Exemplo n.º 2
0
int zmq::msg_t::move(msg_t &src_) {
    //  Check the validity of the source.
    if (unlikely (!src_.check())) {
        errno = EFAULT;
        return -1;
    }

    int rc = close();
    if (unlikely (rc < 0))
        return rc;

    *this = src_;

    rc = src_.init();
    if (unlikely (rc < 0))
        return rc;

    return 0;
}