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=-0.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FREEMAIL_REPLY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d775e66c331d34f6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-03 16:50:28 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!chcgil2-snh1.gtei.net!news.bbnplanet.com!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: protected type question From: James Rogers References: <4948f537.0401031258.62a7cdc7@posting.google.com> Message-ID: User-Agent: Xnews/5.04.25 Date: Sun, 04 Jan 2004 00:50:28 GMT NNTP-Posting-Host: 12.73.180.46 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1073177428 12.73.180.46 (Sun, 04 Jan 2004 00:50:28 GMT) NNTP-Posting-Date: Sun, 04 Jan 2004 00:50:28 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:4090 Date: 2004-01-04T00:50:28+00:00 List-Id: shoko2004@hotmail.com (shoko) wrote in news:4948f537.0401031258.62a7cdc7@posting.google.com: > i have the following package: > > generic > type Message is private; > package Broadcasts is > protected type Broadcast is > procedure Send(This_Message : in Message); > procedure Send_all(This_Message : in Message); > entry wait(A_Message : out Message ); > private > Message_Arrived:Boolean:=False; > The_Message:Message; > end Broadcast ; > end Broadcasts ; > ---------------------------------------------------------------- > > package body Broadcasts is > protected body Broadcast is > entry wait(A_Message : out Message ) when Message_Arrived is > begin > if wait'Count=0 then > Message_Arrived:=False; > end if; > A_Message:=The_Message; > end wait; > > procedure Send (This_Message : in Message ) is > begin > if wait'Count>0 then > Message_Arrived:=True; > The_Message:=This_Message; > end if; > end Send; > > procedure send_all(This_Message : in Message )is > begin > Message_Arrived:=True; > The_Message:=This_Message; > end send_all; > end Broadcast ; > end Broadcasts; > ---------------------------------------------------------------- > > in the main procedure i am trying to create a task > 1.I get compiltaion error:"wait" not decllared in "str_broadcasts" > what am i doing wrong? > > 2.In the broadcasts package i use send all procedure that will free > all waiting tasks is this is the right way? > > > > with broadcasts; > with Ada.Strings.Unbounded; > use Ada.Strings.Unbounded; > > procedure main_broadcast is > > subtype message is Unbounded_String; > package str_broadcasts is new broadcasts(message); > a:message :=To_Unbounded_String("hello"); buffer : str_broadcasts.broadcast; > > TASK messages; > > task body messages is > m:message; > begin > loop > str_broadcasts.wait(a);<-- compilation error buffer.wait(a); > end loop; > end messages; > begin > > null; > end main_broadcast; > str_broadcasts is the name of the instantiated package. str_broadcasts.broadcast is the name of the protected type. You need to make an instance of that protected type. My addition creates an instance named "buffer". Jim Rogers