From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <676c3c4f0612060835x414a779ao6e1f5fcbe021aba9@mail.gmail.com> Date: Wed, 6 Dec 2006 11:35:18 -0500 From: "Richard Bilson" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] OT: cannonical set of queue ops In-Reply-To: <15215407ef3dbfddfed3946505e2dc78@quintile.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <15215407ef3dbfddfed3946505e2dc78@quintile.net> Topicbox-Message-UUID: ebad25bc-ead1-11e9-9d60-3106f5b1d025 > Are we suffering from a lack of vision, or is some way of checking the > number of items on a queue inevitable? The problem with these sorts of functions is that the results that they give can't, in general, be used for much. For instance, if IsQueueEmpty returns "true", that answer isn't worth very much if, by the time you act on that information, some other thread could have added an item to the queue. They're dangerous functions to have around, since often people will be tempted to use them inappropriately, relying on the answer even where the potential exists for other threads to perform concurrent operations on the same queue. But there are certainly cases where their use is appropriate, and it sounds like you have one of those cases here (assuming no thread or interrupt handler is going to add more items to the queue as it drains). In summary: it can be useful to have such a function, but it probably won't (and shouldn't) be used often.