On Tue, 2 Jul 2002, Julian Elischer wrote:

Having just re-read my own mail

I think I agree with jonathan now..
I think we neeed to either:
1/ augment the man page  giving an example of how to do
multiple removes from a list/queue.
2/ Explain in detail why using XXXX_FOREACH()
is bad for this, and showing the alternative.
3/ Add something to the API that makes this easy to do.
designing the API addition is tricky. Jonathan's effort
was quite good, though I wonder if there is any way we can get it done
without needing the decalration of 'tmp' separatly.
(I can't think of a way).



> /* 
>  * Move any threads that should be suspended from the run queue
>  * to the suspend queue.
>  */
> TAILQ_FOREACH(from run queue) {
>       if (something) {
>               TAILQ_REMOVE(element from run queue)
>               TAILQ_INSERT_TAIL(onto suspend queue)
>       }
> }
> 
> Now, at first glance, the documentation suggests this should work, even
> though we know it won't. but it doesn't crash.. it just terminates on the
> first transfer because it reaches the end of the queue.. the suspend queue
> that is..

TAILQ_FOREACH_REMOVABLE or TAILQ_FOREACH_SAFE
(I prefer the first) are my suggestions for the name.)




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to