Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zmsg_recv_nowait #65

Closed
xekoukou opened this issue Aug 7, 2012 · 3 comments
Closed

zmsg_recv_nowait #65

xekoukou opened this issue Aug 7, 2012 · 3 comments

Comments

@xekoukou
Copy link

xekoukou commented Aug 7, 2012

I am trying to create a priority queue that receives all messages from the zmq queue.

In that case, having a zloop informs you if there is a message or not, not the queue size. With a zmsg_recv_nowait , you can get all remaining messages, do some work and then return to the zloop.

I am new to this, so tell me if there is a better way of doing this.

@felipecruz
Copy link
Member

Your issue is because you want zmsg_recv_nowait and it does not exist ?

You can call zframe_recv_nowait instead of zframe_recv (which blocks) until !zframe_more(frame).

This is the source code from zmsg_recv()

zmsg_t *
zmsg_recv (void *socket)
{
    assert (socket);
    zmsg_t *self = zmsg_new ();
    if (!self)
        return NULL;

    while (1) {
        zframe_t *frame = zframe_recv (socket);
        if (!frame) {
            zmsg_destroy (&self);
            break;              //  Interrupted or terminated
        }
        if (zmsg_add (self, frame)) {
            zmsg_destroy (&self);
            break;
        }
        if (!zframe_more (frame))
            break;              //  Last message frame
    }
    return self;
}

It help? :)

@xekoukou
Copy link
Author

Yea, I know its that easy. :P I just dont feel like pulling for such a popular repository. If you think it is usefull to others, you can make the change, otherwise close this issue.

@felipecruz
Copy link
Member

If you want, you can send a PR and I'll review it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants