comp.lang.ada
 help / color / mirror / Atom feed
* Streams and Concurrency
@ 1998-12-30  0:00 James S. Rogers
  1998-12-29  0:00 ` David Botton
  1998-12-30  0:00 ` dennison
  0 siblings, 2 replies; 35+ messages in thread
From: James S. Rogers @ 1998-12-30  0:00 UTC (permalink / raw)


A question was recently raised about task safe use of streams.
A stream is just as safe in a concurrent design as any other shared
resource.  That is, unless it is properly protected, it is not at all safe.
The same may be said of shared memory, or shared files.

There are two classical solutions to this problem.  The first is to
elminate the shared resource, and have a single, unshared resource
for each task.  The second is to protect the shared resource by having
only one task at a time access the resource.

Classical database engines control concurrent access to the
database by forcing all tasks to access the database through a
single database engine.  The same sort of thing can be achieved
in Ada in a couple of ways.  One way is to have all tasks send
messages to a single controlling task through a rendezvous.  This
would be the typical Ada 83 approach.  The more modern, and
more efficient approach in Ada 95 is to have encapsulate the stream
in a protected object.  All access will be correctly and effectively
controlled by the protected object mechanism.

When you use a protected object the "read" and "write" procedures
or entries must have a parameter of a class-wide type.  The
class-wide type parameter will allow the protected object to
read and write a wide range of otherwise heterogeneous data items
to and from the stream.  The stream may simply be an instance of
Ada.Streams.Stream_Io, or it may be a custom-made stream of
your own choosing.  The implementation will be irrelevant to the
tasks accessing the protected object.  It will also be irrelevant to the
protected object itself.

Jim Rogers
Colorado Springs, Colorado USA






^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~1999-01-11  0:00 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-30  0:00 Streams and Concurrency James S. Rogers
1998-12-29  0:00 ` David Botton
1998-12-30  0:00   ` dennison
1998-12-30  0:00     ` Tucker Taft
1998-12-30  0:00       ` Robert I. Eachus
1998-12-30  0:00         ` Tucker Taft
1998-12-31  0:00         ` dennison
1998-12-31  0:00           ` robert_dewar
1998-12-31  0:00             ` dennison
1999-01-01  0:00               ` robert_dewar
1999-01-04  0:00           ` Robert I. Eachus
1998-12-30  0:00       ` dennison
1998-12-31  0:00         ` robert_dewar
1998-12-30  0:00   ` James S. Rogers
1998-12-30  0:00     ` dennison
1998-12-30  0:00       ` James S. Rogers
1999-01-04  0:00       ` Robert I. Eachus
1998-12-31  0:00     ` Jean-Pierre Rosen
1998-12-31  0:00       ` dewar
1998-12-31  0:00         ` Ada-G, was " Tom Moran
1999-01-01  0:00           ` dewar
1999-01-01  0:00             ` Larry Kilgallen
1999-01-01  0:00           ` Brian Rogoff
1999-01-04  0:00             ` Robert I. Eachus
1999-01-08  0:00               ` Mats Weber
1999-01-08  0:00                 ` Robert I. Eachus
1999-01-08  0:00         ` Mats Weber
1999-01-08  0:00           ` Tucker Taft
1998-12-31  0:00       ` dewar
1998-12-31  0:00         ` dennison
1999-01-04  0:00         ` Jean-Pierre Rosen
1999-01-04  0:00           ` robert_dewar
1998-12-30  0:00 ` dennison
1998-12-30  0:00   ` Robert I. Eachus
1999-01-11  0:00   ` Bulk synchronous model for IO (was Re: Streams and Concurrency) Kevin Rigotti

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