comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Post hoc making a type thread safe
Date: Tue, 10 Jun 2008 19:35:39 -0500
Date: 2008-06-10T19:35:39-05:00	[thread overview]
Message-ID: <4YOdnT-22cpGgNLVnZ2dnUVZ_hzinZ2d@comcast.com> (raw)
In-Reply-To: 6b7vr9F3b6cjlU1@mid.individual.net

This isn't exactly what you appear to be asking for, but perhaps
it would do what you need.

In Claw.Sockets, it's desirable to avoid one thread trying to do
something with a socket while another thread is in the middle of
some activity with that socket.  Our solution was a Controlled
type whose declaration at the beginning of a procedure would
raise an exception if the socket is already busy having something
done to it by another task, or would set a Busy flag if the socket
is not busy.  On leaving the routine the Finalize will clear the
Busy state.

Once the mechanism is set up, this just requires a single line declaration
    Check_Busy : Check_Busy_Type(Socket'unchecked_access);
to be included at the beginning of each routine to be interlocked.



      parent reply	other threads:[~2008-06-11  0:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 18:36 Post hoc making a type thread safe Alex R. Mosteo
2008-06-10 19:42 ` Dmitry A. Kazakov
2008-06-11 11:35   ` Alex R. Mosteo
2008-06-11  0:35 ` tmoran [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox