From owner-freebsd-current Tue Jul 2 17: 0:15 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8349537B400 for ; Tue, 2 Jul 2002 17:00:12 -0700 (PDT) Received: from rwcrmhc51.attbi.com (rwcrmhc51.attbi.com [204.127.198.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98CA143E13 for ; Tue, 2 Jul 2002 17:00:11 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc51.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020703000011.NJEH24728.rwcrmhc51.attbi.com@InterJet.elischer.org>; Wed, 3 Jul 2002 00:00:11 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id QAA99313; Tue, 2 Jul 2002 16:54:44 -0700 (PDT) Date: Tue, 2 Jul 2002 16:54:43 -0700 (PDT) From: Julian Elischer To: Terry Lambert Cc: Garrett Wollman , Jonathan Lemon , current@FreeBSD.ORG Subject: Re: additional queue macro In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message