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,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx21.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:35.0) Gecko/20100101 Thunderbird/35.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Broadcasting message to OTHER NODES References: <5c3b6561-8a9e-4c82-b7f9-7aba466bac12@googlegroups.com> <5633f27b-ffdd-47f3-a32b-9992d67ff135@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <2wWZv.405968$w82.129032@fx21.iad> X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Fri, 10 Oct 2014 19:33:18 UTC Organization: TeraNews.com Date: Fri, 10 Oct 2014 13:33:13 -0600 X-Received-Bytes: 3299 X-Received-Body-CRC: 4117806888 Xref: news.eternal-september.org comp.lang.ada:22330 Date: 2014-10-10T13:33:13-06:00 List-Id: On 10/10/2014 12:42 PM, Stribor40 wrote: > Well i would mark each node/task as 1,2,3,4,5,6. > I am not sure how i would mark each partner but assuming that > i mark each partner somehow so each node/task knows about its > 2 partners.I would like to keep a track off each time turnoff > was sent and knowledge was received. The /how/ is probably the second-most important problem, the primary problem being the creation of the tasks... which is, of course, dependent on the first problem: how they know about each other. I was thinking something like the following: Package Nodes is type Node_Interface is task interface; -- Entry specs here. (Note they must be written in procedure form.) type Node_Access is access Node_Interface; type Node_List is array(Positive range <>) of not null Node_Access; Function Null_List return not null access Node_List is ( New Node_List'(2..1 => <>) ); Function Make_Network(Size : Natural) return Node_List; task type Node( Neighbors : not null access Node_List ) is new Node_Interface with end Node; End Nodes; -------------- with Ada.Text_IO; Package body Nodes is task body Node is begin null; Ada.Text_IO.Put_Line( "Done." ); end Node; Function Make_Network(Size : Natural) return Node_List is begin return Result : Node_List( 1..Size ) do for Index in Result'Range loop declare subtype Head is Natural range Result'First..Natural'Pred(Index); subtype Tail is Natural range Natural'Succ(Index)..Result'Last; Item : Node_Access renames Result(Index); Fore : Node_List renames Result(Head); Aft : Node_List renames Result(Tail); begin Result(Index):= new Node'( New Node_List'(Fore & Aft) ); end; end loop; end return; end Make_Network; End Nodes; ---------------- The problem with the above is that the compiler tells me: "nodes.adb:26:32: initialization not allowed for limited types" So, I'm not sure exactly how you'd go about creating an in-place network (w/ no dynamic node addition/deletion)... although it seems perfectly reasonable to me to do so.