Re: Multitasking and containers



On Tue, 28 Nov 2006 11:31:13 +0100, Georg Bauhaus wrote:

On Tue, 2006-11-28 at 09:50 +0100, Dmitry A. Kazakov wrote:
On Tue, 28 Nov 2006 02:19:55 GMT, Matthew Heaney wrote:
It is easy to imagine a
situation (massively parallel computing with shared memory) where the loss
could be huge.

I have learned that Ada tasking is defined at a relatively
high level. Suppose you are writing highly specialized low
level software, such as when taking advantage of a specific
computer's architecture at the system or hardware level.
It is easy for me to imagine that you are working way below
Ada's tasking level. Are you suggesting that this is the
normal mode of using a high level programming language
that supports tasking?

I didn't mean Ada tasking at all [*]. I meant explicitly one concrete
design solution: a container with mutable reads wrapped into a protected
object's procedure.

What makes you think that my proposal to decouple the mutable context from
the container data type is any lower level than fighting with side-effects
by rough locking? It is merely a design question. You replace:

function Find
( Container : access Dictionary;
Token : Key
) return Topic;

with

function Find
( Container : Dictionary;
Token : Key;
Context : access Environment
) return Topic;

where Context provides protected interface to shared mutable data, which
hopefully need not to changed upon each call.

or else you use mix-in on the container type:

type Dictionary (Context : access Environment) is ...;

-------------------------------------------
* If your question concerns whether Ada's tasking primitives are
composable with other language features. Then the answer is clear and
unambiguous. They are *not*.

There are many *objective* reasons for this unhappy situation. Objective in
the sense that it would be unfair and just wrong to address them to the
language design faults. If you disagree with that, then you should have
dismissed the design of Ada.Containers for being task-unsafe. Because the
following two statements are mutually incompatible:

1. Ada.Containers may be task-unsafe
2. Ada tasking primitives are composable

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.