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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1dc110ae98b0b7f1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Task question Date: Mon, 10 Dec 2007 18:40:42 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <31235206-1025-467c-8444-07a8eacc9b48@e6g2000prf.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1197330045 4286 192.74.137.71 (10 Dec 2007 23:40:45 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 10 Dec 2007 23:40:45 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:af+w6t3A+s2qUyf7cSleeCL8+0U= Xref: g2news1.google.com comp.lang.ada:18878 Date: 2007-12-10T18:40:42-05:00 List-Id: shaunpatterson@gmail.com writes: > procedure Test is > begin > > -- Call a callback function that may take a long time > FuncPtr.all > > > -- Continue other processing here > > end Test; > > > Is there any way to encapsulate the callback function call in another > task WITHOUT making > the function -- the function called by funcptr.all -- a new task? The task can call the function (or more likely, procedure). Here's one way: task type Call_Procedure (Action : not null access procedure); (Or use whatever profile you want.) task body Call_Procedure is begin Action.all; end Call_Procedure; Do you want Test to return while the procedure is still going? If no, declare a local object of type Call_Procedure in Test -- then Test will wait for the task to terminate before returning. If yes, declare an access-to-Call_Procedure type outside Test, and allocate an object inside Test using "new". - Bob