From: "Mauricio Fernández" Date: 2003-02-08T18:50:38+09:00 Subject: Re: drb and signals On Sat, Feb 08, 2003 at 02:57:35AM +0900, ahoward wrote: > On Sat, 8 Feb 2003, Eric Hodel wrote: > > > ah-ha! You really want #synchronize, it does the waiting for you, and > > its not a busy-wait. > > > > class DistributedObject > > def method > > sem.synchronize { yield } > > end > > end > > not in my case actually : i have an Array of PGconns, iff i cannot obtain the > lock on _any_ of them, i must go to sleep on a ConditionVarible and am woken > up appropriately (when a connection becomes free). eg. there is a Mutex for > each connection AND a Mutex on the array of connections. the threads which > release the lock on a particular connection also notify the condition > variable. in that way, i DO use the non-busy-wait feature of sem.synchronize > _but_ this is wrapped around the entire array of connections. now, if i used > sem.synchronize on conns[0], for example, conn[1] would never be used! eg. i > cannot _automatically_ go to sleep just because a _particular_ conn is not > available. i only should go to sleep in _all_ connections are not available. > does that make any sense? Might not be completely pertinent, but have you seen http://www.rubygarden.org/ruby?ObjectPoolingAndThreading ? I think it can be made to work the way you want and it doesn't use busy-wait. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com And Bruce is effectively building BruceIX -- Alan Cox