--YLwdFo+Xu6B7B0Yp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

ahoward (ahoward / fsl.noaa.gov) wrote:

> On Sat, 8 Feb 2003, Eric Hodel wrote:
>=20
> > ah-ha!  You really want #synchronize, it does the waiting for you, and
> > its not a busy-wait.
>=20
> not in my case actually :  i have an Array of PGconns, iff i cannot obtai=
n the
> lock on _any_ of them, i must go to sleep on a ConditionVarible and am wo=
ken
> 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 whi=
ch
> 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.synchro=
nize
> _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!  e=
g. 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 availa=
ble.
> does that make any sense?

Yes, the devil in the details :)

> > (I hadn't realized that try_lock worked this way, I thought it just told
> > you if the lock was available or not... learn something new every day :)
>=20
> very handy in the above case - sometimes you want to continue doing
> _something_ even if you could not aquire the lock (like trying to obtain
> _another_ one)

/me makes a mental sticky-note

--=20
Eric Hodel - drbrain / segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04


--YLwdFo+Xu6B7B0Yp
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (FreeBSD)

iD8DBQE+Q/q2MypVHHlsnwQRAu9nAKCDx4HSE1tokXtDRUSRQhQp8ChATgCdH8m5
0YGwD0wUhE4T6lP1z1IFatI=
=fZf0
-----END PGP SIGNATURE-----

--YLwdFo+Xu6B7B0Yp--