void nn_priolist_rm (struct nn_priolist *self, struct nn_pipe *pipe, struct nn_priolist_data *data) { if (nn_list_item_isinlist (&data->item)) nn_list_erase (&self->slots [data->priority - 1].pipes, &data->item); nn_list_item_term (&data->item); }
void nn_priolist_rm (struct nn_priolist *self, struct nn_pipe *pipe, struct nn_priolist_data *data) { struct nn_priolist_slot *slot; struct nn_list_item *it; /* Non-active pipes don't need any special processing. */ if (!nn_list_item_isinlist (&data->item)) { nn_list_item_term (&data->item); return; } /* If the pipe being removed is not current, we can simply erase it from the list. */ slot = &self->slots [data->priority - 1]; if (slot->current != data) { nn_list_erase (&slot->pipes, &data->item); nn_list_item_term (&data->item); return; } /* Advance the current pointer (with wrap-over). */ it = nn_list_erase (&slot->pipes, &data->item); slot->current = nn_cont (it, struct nn_priolist_data, item); nn_list_item_term (&data->item); if (!slot->current) { it = nn_list_begin (&slot->pipes); slot->current = nn_cont (it, struct nn_priolist_data, item); }
void nn_dist_rm (struct nn_dist *self, struct nn_pipe *pipe, struct nn_dist_data *data) { if (nn_list_item_isinlist (&data->item)) { --self->count; nn_list_erase (&self->pipes, &data->item); } nn_list_item_term (&data->item); }
static void nn_astream_terminating_closed (const struct nn_cp_sink **self, struct nn_usock *usock) { struct nn_astream *astream; astream = nn_cont (self, struct nn_astream, sink); /* Ignore if I don't belong to the bstream. */ if (nn_list_item_isinlist (&astream->item)) nn_bstream_astream_closed (astream->bstream, astream); nn_list_item_term (&astream->item); nn_free (astream); }
void nn_list_insert (struct nn_list *self, struct nn_list_item *item, struct nn_list_item *it) { nn_assert (!nn_list_item_isinlist (item)); item->prev = it ? it->prev : self->last; item->next = it; if (item->prev) item->prev->next = item; if (item->next) item->next->prev = item; if (!self->first || self->first == it) self->first = item; if (!it) self->last = item; }
struct nn_list_item *nn_list_erase (struct nn_list *self, struct nn_list_item *item) { struct nn_list_item *next; nn_assert (nn_list_item_isinlist (item)); if (item->prev) item->prev->next = item->next; else self->first = item->next; if (item->next) item->next->prev = item->prev; else self->last = item->prev; next = item->next; item->prev = NN_LIST_NOTINLIST; item->next = NN_LIST_NOTINLIST; return next; }
void nn_list_item_term (struct nn_list_item *self) { nn_assert (!nn_list_item_isinlist (self)); }