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 X-Google-Thread: 103376,57893ac51069959a,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.68 with SMTP id nq4mr6005230pbc.2.1327347159658; Mon, 23 Jan 2012 11:32:39 -0800 (PST) Path: lh20ni215956pbb.0!nntp.google.com!news1.google.com!postnews.google.com!k29g2000vbl.googlegroups.com!not-for-mail From: Ada BRL Newsgroups: comp.lang.ada Subject: "C - like: THIS" pointer to a task type inside a task function Date: Mon, 23 Jan 2012 11:32:39 -0800 (PST) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 164.11.203.58 Mime-Version: 1.0 X-Trace: posting.google.com 1327347159 2650 127.0.0.1 (23 Jan 2012 19:32:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 23 Jan 2012 19:32:39 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k29g2000vbl.googlegroups.com; posting-host=164.11.203.58; posting-account=yig7mwoAAAAAcduNbH7Dpal1sjCSAijA User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUARELSCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-01-23T11:32:39-08:00 List-Id: 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!