int nn_xreq_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xreq *xreq; struct nn_xreq_data *data; int sndprio; int rcvprio; size_t sz; xreq = nn_cont (self, struct nn_xreq, sockbase); sz = sizeof (sndprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_SNDPRIO, &sndprio, &sz); nn_assert (sz == sizeof (sndprio)); nn_assert (sndprio >= 1 && sndprio <= 16); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xreq_data), "pipe data (req)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_lb_add (&xreq->lb, &data->lb, pipe, sndprio); nn_fq_add (&xreq->fq, &data->fq, pipe, rcvprio); return 0; }
static int nn_xpull_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpull *xpull; struct nn_xpull_data *data; xpull = nn_cont (self, struct nn_xpull, sockbase); data = nn_alloc (sizeof (struct nn_xpull_data), "pipe data (pull)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_fq_add (&xpull->fq, pipe, &data->fq, 8); return 0; }
int nn_xbus_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xbus *xbus; struct nn_xbus_data *data; xbus = nn_cont (self, struct nn_xbus, sockbase); data = nn_alloc (sizeof (struct nn_xbus_data), "pipe data (xbus)"); alloc_assert (data); nn_fq_add (&xbus->inpipes, pipe, &data->initem, 8); nn_dist_add (&xbus->outpipes, pipe, &data->outitem); nn_pipe_setdata (pipe, data); return 0; }
int nn_xsurveyor_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsurveyor *xsurveyor; struct nn_xsurveyor_data *data; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); data = nn_alloc (sizeof (struct nn_xsurveyor_data), "pipe data (xsurveyor)"); alloc_assert (data); data->pipe = pipe; nn_fq_add (&xsurveyor->inpipes, pipe, &data->initem, 8); nn_dist_add (&xsurveyor->outpipes, pipe, &data->outitem); nn_pipe_setdata (pipe, data); return 0; }
static int nn_xsub_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsub *xsub; struct nn_xsub_data *data; int rcvprio; size_t sz; xsub = nn_cont (self, struct nn_xsub, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xsub_data), "pipe data (sub)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_fq_add (&xsub->fq, &data->fq, pipe, rcvprio); return 0; }
int nn_xreq_add (struct nn_sockbase *self, struct nn_pipe *pipe) { int rc; struct nn_xreq *xreq; struct nn_xreq_data *data; int sndprio; size_t sz; xreq = nn_cont (self, struct nn_xreq, sockbase); sz = sizeof (sndprio); rc = nn_sockbase_getopt (&xreq->sockbase, NN_SNDPRIO, &sndprio, &sz); errnum_assert (rc == 0, -rc); nn_assert (sz == sizeof (sndprio)); data = nn_alloc (sizeof (struct nn_xreq_data), "pipe data (req)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_lb_add (&xreq->lb, pipe, &data->lb, sndprio); nn_fq_add (&xreq->fq, pipe, &data->fq, 8); return 0; }
int nn_xsurveyor_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsurveyor *xsurveyor; struct nn_xsurveyor_data *data; int rcvprio; size_t sz; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xsurveyor_data), "pipe data (xsurveyor)"); alloc_assert (data); data->pipe = pipe; nn_fq_add (&xsurveyor->inpipes, &data->initem, pipe, rcvprio); nn_dist_add (&xsurveyor->outpipes, &data->outitem, pipe); nn_pipe_setdata (pipe, data); return 0; }