From: Shark8 <OneWingedShark@gmail.com>
Subject: Re: Broadcasting message to OTHER NODES
Date: Fri, 10 Oct 2014 13:33:13 -0600
Date: 2014-10-10T13:33:13-06:00 [thread overview]
Message-ID: <2wWZv.405968$w82.129032@fx21.iad> (raw)
In-Reply-To: <f0a56681-5f88-4251-b53a-ff52364bd41c@googlegroups.com>
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.
prev parent reply other threads:[~2014-10-10 19:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-10 16:23 Broadcasting message to OTHER NODES Stribor40
2014-10-10 17:43 ` Niklas Holsti
2014-10-10 17:51 ` Stribor40
2014-10-10 18:15 ` Niklas Holsti
2014-10-10 18:33 ` Niklas Holsti
2014-10-10 18:42 ` Stribor40
2014-10-10 19:33 ` Shark8 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox