> Is there a big problem with the rule being that a try_get() > succeeds if and only if BOTH the mailbox queue size is > greater than 0 AND the queue of processes suspended on > a blocking get has a size of 0? Either try_get() jumps the queue of waiters if it succeeds (Dave Rich's proposal), or it loses its place in the queue if it fails (Mark's proposal). Neither behaviour is likely to satisfy all users. Consider a doughnut stall. There is a FIFO queue of customers, and FIFO delivery of doughnuts to customers as they are prepared. Now I arrive at the doughnut stall. If I see no queue of customers, and no doughnuts, I may choose to go away and return later (try_get()). If I see a queue of customers, I do not go away to return later, as I thereby lose my place in the queue. Instead I put my friend in the queue as a proxy, and occasionally take a look to see how far down the queue my friend has progressed. When my friend is served, he will stand nearby and I can pick up my doughnut whenever I choose. My try_get() waits on the proxy (my friend) and not on the main queue of customers. To implement this kind of mechanism we need some additional information that's not available in mailboxes right now. The failing return value from try_get() needs to distinguish between "queue of customers" and "no doughnuts", so that the caller can make a sensible choice of whether to put its friend (proxy process) in the queue. If we follow Mark's suggestion, we *nearly* have this already - if num() is nonzero and try_get() fails, then there is a queue of customers - but obviously it would be better to have a single call to test both things atomically. Mutatis mutandis for try_put(), of course. -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 Email: jonathan.bromley@doulos.com Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Feb 14 07:04:29 2007
This archive was generated by hypermail 2.1.8 : Wed Feb 14 2007 - 07:04:43 PST