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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Task question Reply-To: anon@anon.org (anon) References: <31235206-1025-467c-8444-07a8eacc9b48@e6g2000prf.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: <13l7j.238158$kj1.79368@bgtnsc04-news.ops.worldnet.att.net> Date: Tue, 11 Dec 2007 00:43:41 GMT NNTP-Posting-Host: 12.64.66.3 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1197333821 12.64.66.3 (Tue, 11 Dec 2007 00:43:41 GMT) NNTP-Posting-Date: Tue, 11 Dec 2007 00:43:41 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:18880 Date: 2007-12-11T00:43:41+00:00 List-Id: -- -- f_p.adb -- with Ada.Text_IO ; procedure F_P is task type Function_Task is entry Function_1 ( X : in Boolean ) ; entry Result_1 ( X : out Boolean ) ; end function_Task ; -- -- This task uses two calls. One activate the function -- and the second returns the function value once valid. -- -- Note: Delays are use to simulate the actual algorithm for -- the function. Normally there are not needed. -- task body Function_Task is W : Boolean ; -- Hold paramter and result value begin -- Function_Task -- Initial or setup functions loop select -- -- Start execution of function -- accept Function_1 ( X : in Boolean ) do W := X ; end Function_1 ; -- -- Routine for function. It could be a function call -- Or code here -- Delay 1.0 ; -- simulate a complex algorithm W := not W ; or -- -- Retrieve function's result if needed wait until -- result is valid -- accept Result_1 ( X : out Boolean ) do X := W ; -- Retrive result. end Result_1 ; or -- -- Allows the task to end, if the program exist -- terminate ; end select ; end loop ; -- shutdown function end function_Task ; procedure put ( V : boolean ) is begin if V then Ada.Text_IO.put ( Item => "True" ) ; else Ada.Text_IO.put ( Item => "False" ) ; end if ; end ; Functions : function_Task ; Z : Boolean := True ; begin -- F_P Ada.Text_IO.put_line ( Item => "Excute Function 1" ) ; Functions.Function_1 ( Z ) ; Put ( Z ) ; Ada.Text_IO.new_line ; Ada.Text_IO.put_line ( Item => "Excute Something Else" ) ; -- -- Now we need the result from Function 1. So we may -- need to wait until result of function is valid. -- Ada.Text_IO.put_line ( Item => "Get Result for function 1" ) ; Functions.Result_1 ( Z ) ; Put ( Z ) ; Ada.Text_IO.new_line ; Ada.Text_IO.put_line ( Item => "Exit Program" ) ; end F_P ; In <31235206-1025-467c-8444-07a8eacc9b48@e6g2000prf.googlegroups.com>, shaunpatterson@gmail.com writes: >Hey, > > What is the best / proper way to spawn a new task so that a >function call can >continue in the background.. like so: > >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? > >Thanks > >-- >Shaun