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: a07f3367d7,c33f8f65997c21d0 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.216.113.70 with SMTP id z48mr257533weg.6.1348083886824; Wed, 19 Sep 2012 12:44:46 -0700 (PDT) Received: by 10.236.170.7 with SMTP id o7mr836139yhl.3.1348083886654; Wed, 19 Sep 2012 12:44:46 -0700 (PDT) Path: ed8ni2292956wib.0!nntp.google.com!i6no7120qas.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 19 Sep 2012 12:44:46 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <476e1044-2371-4a8a-b0bf-2590bdc0b98d@googlegroups.com> Subject: Re: Problem with task component From: Adam Beneschan Injection-Date: Wed, 19 Sep 2012 19:44:46 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-09-19T12:44:46-07:00 List-Id: On Wednesday, September 19, 2012 11:22:08 AM UTC-7, Simon Wright wrote: > If a Limited_Controlled type has a component of a task type, is it wrong > to call an entry of the task from Initialize? When I do, the caller > blocks. >=20 > package Chips is >=20 > type Chip is limited private; >=20 > private=20 >=20 > task type Polling_Task (For_Chip : not null access Chip) is > entry Start; > entry Stop; > end Polling_Task; >=20 > type Chip is new Ada.Finalization.Limited_Controlled with record > Polling_Interval : Duration :=3D 0.1;=20 > Poller : Polling_Task (For_Chip =3D> Chip'Access); > end record; >=20 > overriding > procedure Initialize (C : in out Chip); >=20 > ... >=20 > package body Chips is >=20 > task body Polling_Task is > begin > accept Start; > ... > end Polling_Task; >=20 > overriding > procedure Initialize (C : in out Chip) > is > begin > C.Poller.Start; <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D sticks h= ere > end Initialize; >=20 > ... >=20 > If the task won't start executing until its instance is completely > elaborated and initialized, I don't need the entry Start in any case. I think the relevant rules are spelled out in 9.2. This specifies when a t= ask is *activated*, and a task can't accept an entry call until it's been a= ctivated. For a task created by an allocator (including a task that's a co= mponent of an allocated object), the task activation is the last thing that= the allocator does (and 7.6(12) confirms that it will happen after Initial= ize). For a task created by a standalone object, e.g. procedure P is C : Chip; X1 : Some_Other_Object; X2 : Another_Object; ... begin ... C.Poller won't get activated until *all* the declared objects have been ini= tialized, including X1 and X2. So I think it's always the case that a task won't be activated until the ou= termost object that encloses it have been completely initialized. So it lo= oks like you don't need Start. -- Adam