From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3cfaa627fc3366de X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Task origin track from a class Date: Tue, 12 Jul 2011 06:57:54 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="9652"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184Fpk5hPlNLnFTMGb5yIFLtHOvZ3DFb+U=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:CfyAw9RZYuJKM0kDIgOgA65P4jA= sha1:q+Gfv+78X1TWKxZp408TkzTh6uY= Xref: g2news2.google.com comp.lang.ada:21145 Date: 2011-07-12T06:57:54+01:00 List-Id: "Rego, P." writes: > I have a class Def_Class which defines a record which is a task. Say: > task type My_Task_Kind; > > type Def_Class is tagged limited > record > Some_Element : Integer; -- or other type anyway > My_Task : My_Task_Kind; > end record; > > and I want to access my class inside the task body, something like > type body My_Task_Kind (Origin: Def_Class) is > begin > if Origin.Some_Element = 1 then > (...) > end if; > end My_Task_Kind; > > So how can I do it? (I tried to use an entry type, but got problems > with limited/non limited types, so asking for help!!) Using a constraint: package Rego is type C; task type T (The_C : access C); type C is tagged limited record The_T : T (C'Access); Done : Boolean := False; end record; end Rego; package body Rego is task body T is begin The_C.Done := True; end; end Rego; with Ada.Text_IO; use Ada.Text_IO; with Rego; procedure Rego_D is The_C : Rego.C; begin Put_Line (Boolean'Image (The_C.Done)); end Rego_D;