QUEUE wq2; QUEUE_INIT(&wq2); In the codes, had written.
在 2016年3月9日星期三 UTC+8下午3:13:28,Xy Wang写道: > > after `QUEUE_ADD(&wq, &wq2)`, `wq2` is not iterable and it is not still a > valid queue header, all you should do is `QUEUE_INIT(&wq2);` > > On Tuesday, March 8, 2016 at 6:03:11 PM UTC+8, Xiaomao Lan wrote: >> >> >> The submitted at github: >> https://github.com/libuv/libuv/issues/754 >> >> The code is modified, but the issue still exist. >> New code: add QUEUE_INIT(&w1.wq); .... QUEUE_INIT(&w4.wq); >> >> >> #include "queue.h" >> #include <stdio.h> >> >> struct uv__work { >> int id; >> void* wq[2]; >> }; >> >> #define QUEUE_DATA(ptr, type, field) \ >> ((type *) ((char *) (ptr) - offsetof(type, field))) >> >> >> static QUEUE wq; >> >> int main() >> { >> struct uv__work *pw; >> QUEUE* q; >> >> QUEUE_INIT(&wq); >> >> struct uv__work w1; >> w1.id = 1; >> QUEUE_INIT(&w1.wq); >> QUEUE_INSERT_TAIL(&wq, &w1.wq); >> >> struct uv__work w2; >> w2.id = 2; >> QUEUE_INIT(&w2.wq); >> QUEUE_INSERT_TAIL(&wq, &w2.wq); >> >> struct uv__work w3; >> w3.id = 3; >> QUEUE_INIT(&w3.wq); >> QUEUE_INSERT_TAIL(&wq, &w3.wq); >> >> >> QUEUE_FOREACH(q, &wq) >> { >> pw = QUEUE_DATA(q, uv__work, wq); >> printf("queue wq data is %d.\n", pw->id); >> } >> printf("-----------------------------\n"); >> >> QUEUE wq2; >> QUEUE_INIT(&wq2); >> >> struct uv__work w4; >> w4.id = 4; >> QUEUE_INIT(&w4.wq); >> QUEUE_INSERT_TAIL(&wq2, &w4.wq); >> >> QUEUE_FOREACH(q, &wq2) >> { >> pw = QUEUE_DATA(q, uv__work, wq); >> printf("queue wq2 data is %d.\n", pw->id); >> } >> printf("-----------------------------\n"); >> >> >> QUEUE_ADD(&wq, &wq2); // add >> >> QUEUE_FOREACH(q, &wq) >> { >> pw = QUEUE_DATA(q, uv__work, wq); >> printf("queue wq data is %d.\n", pw->id); >> } >> printf("-----------------------------\n"); >> >> QUEUE_FOREACH(q, &wq2) >> { >> pw = QUEUE_DATA(q, uv__work, wq); >> printf("queue wq2 data is %d.\n", pw->id); >> } >> printf("-----------------------------\n"); >> >> return 0; >> } >> >> >> >> >> -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
