item->queue = mq;
item->next = dtio->io_list;
dtio->io_list = item;
+ dtio->io_list_iter = NULL;
return 1;
}
else dtio->io_list = item->next;
/* the queue itself only registered, not deleted */
free(item);
+ dtio->io_list_iter = NULL;
return;
}
prev = item;
/** find a new message to write, search message queues, false if none */
static int dtio_find_msg(struct dt_io_thread* dtio)
{
- struct dt_io_list_item* item = dtio->io_list;
+ struct dt_io_list_item* item;
+
+ if(dtio->io_list_iter)
+ item = dtio->io_list_iter;
+ else item = dtio->io_list;
+ /* use the next queue for the next message lookup,
+ * if we hit the end(NULL) the NULL restarts the iter at start. */
+ if(item)
+ dtio->io_list_iter = item->next;
+
while(item) {
if(dtio_find_in_queue(dtio, item->queue))
return 1;
void* event_base;
/** list of queues that is registered to get written */
struct dt_io_list_item* io_list;
+ /** iterator point in the io_list, to pick from them in a
+ * round-robin fashion, instead of only from the first when busy.
+ * if NULL it means start at the start of the list. */
+ struct dt_io_list_item* io_list_iter;
/** thread id, of the io thread */
ub_thread_type tid;
/** file descriptor that the thread writes to */