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;
}
Exemplo n.º 3
0
static inline int get_msg(msg_t& msg,int id){
	int ret;
	std::string str;
	Json::Reader reader;

	msg.clear();
	assert_perror(id < 0);
	if(!get_str_from_fd(id,str))
		return 0;
	reader.parse(str,msg,false);

	return 1;
}
Exemplo n.º 4
0
bool zmq::pipe_t::is_delimiter (msg_t &msg_)
{
    return msg_.is_delimiter ();
}