comp.lang.ada
 help / color / mirror / Atom feed
From: Ada BRL <ada.brl.2011@gmail.com>
Subject: "C - like: THIS" pointer to a task type inside a task function
Date: Mon, 23 Jan 2012 11:32:39 -0800 (PST)
Date: 2012-01-23T11:32:39-08:00	[thread overview]
Message-ID: <ca5e2bb1-52e1-43fa-bd06-49a02ce29c7c@k29g2000vbl.googlegroups.com> (raw)

Dear all,

I'm experiencing an issue about local and not local pointers...

I've N clients and one server that communicate each other.
The N clients retrieve data dynamically, send it to the server throgh
enrty call (obviously the server can accept just one call per time)
and wait for the reply from the server (through accept statement).
For this reason the server needs to know on which client call the
entry:
one time could be the 3th, another the 1st and so on...

This is my - deeply simplified - framework:

package P1 is

	task type T1 is
		entry Retrieve_Data(Data : String);
	end T1;


	task type T2 is
		entry Retrieve_Data(Data : String);
	end T2;


	task type T3 is
		entry Retrieve_Data(Data : String);
	end T3;


end P1;

package body P1 is

	task body T1 is

		Data : String;

	begin
		while True loop

			-- retrieve somehow data

			T4.Send_Data(Data);

			accept Retrieve_Data(Data);

		end loop;
	end T1;


	task body T2 is

		Data : String;

	begin
		while True loop

			-- retrieve somehow data

			T4.Send_Data(Data);

			accept Retrieve_Data(Data);

		end loop;
	end T2;


	task body T3 is

		Data : String;

	begin
		while True loop

			-- retrieve somehow data

			T4.Send_Data(Data);

			accept Retrieve_Data(Data);

		end loop;
	end T3;

end P1;


-- other file


package P2 is

	task type T4 is
		entry Send_Data(Data : String; Ti : task_pointer_type);
	end T4;
end P2;

package body P2 is

	task body T4 is

		Data : String;

	begin
		while True loop

			accept Send_Data(Data, Ti) do -- ===> Problem here! How can I
retrieve Ti object. I think I need a "this" pointer inside the task
body. Ti has to notify T4 who's the sender of data.

			-- do some stuff

			end Send_Data;

			Ti.Retrieve_Data(Data); -- ===> Problem here! How can I retrieve Ti
object

		end loop;
	end T4;

end P2;

I thought to create a task interface (because abstract types for tasks
are illegal) in order to use a dynamic dispatching inside Send_Data,
in the example identified by the "i" index of Task.


--- other file

package P_Interface

	type Tsk is task interface;
	type Tsk_ptr is access all Tsk'Class;

end P_Interface;

I've tried in so many ways (inserting local types into the tasks,
outiside, into the interface, using explicit casting and so on) to get
the things working but without any good outcomes...
I even had some problems of circular dependency but eventually I've
solved them with "limited with" directive.
No problems (for this moment =) ) for the T4 reference.

May you help me, please =)?
I think this is a quite common problem and so I'm optimistic to
receive some useful replies!

Thank you very much!



             reply	other threads:[~2012-01-23 19:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23 19:32 Ada BRL [this message]
2012-01-23 19:59 ` "C - like: THIS" pointer to a task type inside a task function Dmitry A. Kazakov
2012-01-23 22:17   ` tmoran
2012-01-24  8:47     ` Dmitry A. Kazakov
2012-01-24 17:12   ` Ada BRL
2012-01-24 18:43     ` Dmitry A. Kazakov
2012-01-25 12:43       ` Ada BRL
2012-01-25 13:48         ` Dmitry A. Kazakov
2012-01-25 15:05           ` Ada BRL
2012-01-25 18:10             ` Dmitry A. Kazakov
2012-01-26 15:19               ` Ada BRL
2012-01-26  4:17           ` Randy Brukardt
2012-01-24 17:27   ` Ada BRL
2012-01-23 20:20 ` Jeffrey Carter
2012-01-24 17:13   ` Ada BRL
2012-01-24  6:39 ` J-P. Rosen
2012-01-25  0:42 ` Adam Beneschan
2012-01-25  0:46   ` Adam Beneschan
2012-01-25  7:38   ` J-P. Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox