comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Taking 'Access of single task/protected object
Date: Thu, 7 Jan 2016 18:30:54 +0100
Date: 2016-01-07T18:30:54+01:00	[thread overview]
Message-ID: <n6m7cl$8tk$1@gioia.aioe.org> (raw)
In-Reply-To: n6m2vi$jt1$1@dont-email.me

On 2016-01-07 17:18, G.B. wrote:
> It seems impossible to take the 'Access (or 'Unchecked_Access)
> of a single task object, since it cannot be made aliased.
> And, I guess, as it is not of a named type, so that there
> is no way to express even an anonymous access type.
>
> This is, I think, the crucial bit of a question (34540199)
> asked at stackoverflow. (The example uses some listener pattern
> which looks like Java written in Ada, but that's not why I'm
> asking.)
>
>    task Single is
>       entry Something;
>    end Single;
>
>    ...some_context (access_discriminant => Single'Access)...

It does not make sense because you cannot declare a discriminant without 
mentioning the task type. Therefore it cannot be anonymous.

[ I leave aside the question if anonymous task/protected object types 
should be allowed:

    type T (Reference : access task is entry Something; end) is ...

Ada's degradation has not reached this low, yet? ]

> So, suppose some_context requires indirect access to a single
> task object, i.e., to one of an anonymous task type.
 > Is there a preferred solution to single-task vs. multiple
 > references?

    task type Single is
       entry Something;
    end Single;
    ...
    Object : aliased Single;
    ...
    type T (Reference : not null access Single) is ...

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

  reply	other threads:[~2016-01-07 17:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 16:18 Taking 'Access of single task/protected object G.B.
2016-01-07 17:30 ` Dmitry A. Kazakov [this message]
2016-01-07 18:16 ` Jeffrey R. Carter
2016-01-07 19:38   ` J-P. Rosen
2016-01-07 23:52   ` Randy Brukardt
2016-01-08  8:52     ` J-P. Rosen
replies disabled

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