--Tg5qL4DubmxJEzuM
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
> > > class DistributedObject
> > >   def method
> > >     Thread.pass while sem.try_lock
> > >     yield
> > >     ensure
> > >       sem.unlock
> >         ^^^
>=20
> > Where is this getting locked?
>=20
> from the pickaxe :
>=20
> try_lock : ref.try_lock -> true or false
>=20
>    Attempts to obtain the lock and
>    returns immediately. Returns true if
>    the lock was granted.
>=20
> so the thread yield control until the lock is granted.

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

(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 :)

> > You could install a signal handler that would unlock the Mutex, but I'm
> > not sure how much work would be involved to make it always do the right
> > thing, as you need to know that _you_ locked it and not some other
> > client (this may or may not be a problem)
>=20
> this is not possible for the reasons you mention.
>=20
> > Why are you getting the sigabrt, anyway?
>=20
> because i am doing a 'ctrl-c' from the client tty.  i am trying to make my
> class super bomber.  with this exception - it seems to be.
>=20
> in general, i am trying to learn what happens in a drb server when a clie=
nt
> aborts or is otherwise terminated prematurely (eg. before the method has
> finished completing)

For one, I'd push the lock as deep as you can get it, no sense locking
when you're not doing something that needs to update protected state
(say, reading or writing a file, calculating statistics, etc.).

As for the real problem here, I'll defer to the rest of the crowd, I
don't feel experienced enough to give such advice :)

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


--Tg5qL4DubmxJEzuM
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQE+Q+mvMypVHHlsnwQRAj+bAJ47o9V87J/9C3OXXD5WYnih1XnMBgCfew04
dNYvUaZAGxyP/jkcZameSLk=
=XV8j
-----END PGP SIGNATURE-----

--Tg5qL4DubmxJEzuM--

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

> On Sat, 8 Feb 2003, Eric Hodel wrote:
>=20
> > > class DistributedObject
> > >   def method
> > >     Thread.pass while sem.try_lock
> > >     yield
> > >     ensure
> > >       sem.unlock
> >         ^^^
>=20
> > Where is this getting locked?
>=20
> from the pickaxe :
>=20
> try_lock : ref.try_lock -> true or false
>=20
>    Attempts to obtain the lock and
>    returns immediately. Returns true if
>    the lock was granted.
>=20
> so the thread yield control until the lock is granted.

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

(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 :)

> > You could install a signal handler that would unlock the Mutex, but I'm
> > not sure how much work would be involved to make it always do the right
> > thing, as you need to know that _you_ locked it and not some other
> > client (this may or may not be a problem)
>=20
> this is not possible for the reasons you mention.
>=20
> > Why are you getting the sigabrt, anyway?
>=20
> because i am doing a 'ctrl-c' from the client tty.  i am trying to make my
> class super bomber.  with this exception - it seems to be.
>=20
> in general, i am trying to learn what happens in a drb server when a clie=
nt
> aborts or is otherwise terminated prematurely (eg. before the method has
> finished completing)

For one, I'd push the lock as deep as you can get it, no sense locking
when you're not doing something that needs to update protected state
(say, reading or writing a file, calculating statistics, etc.).

As for the real problem here, I'll defer to the rest of the crowd, I
don't feel experienced enough to give such advice :)

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

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

iD8DBQE+Q+mvMypVHHlsnwQRAj+bAJ47o9V87J/9C3OXXD5WYnih1XnMBgCfew04
dNYvUaZAGxyP/jkcZameSLk=
=XV8j
-----END PGP SIGNATURE-----