comp.lang.ada
 help / color / mirror / Atom feed
* Using the "Terminated" aspect for a task passed to a generic
@ 2018-04-23 14:20 NiGHTS
  2018-04-23 15:40 ` AdaMagica
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: NiGHTS @ 2018-04-23 14:20 UTC (permalink / raw)


Having looked carefully through 2 Ada reference books, one dedicated to tasking, and using Google to no end, I am stumped on the following Ada dilemma. 

generic

        type Managed_Task_Type is limited private;

package WD is

        task WD_Thread;

end WD;

package body WD is

        task body WD_Thread is
        
                M : Managed_Task_Type;
        begin
        
                loop
                        if M'Terminated then
                        
                                exit;
                        end if;
                        
                end loop;
        
        end WD_Thread;
        
end WD; 

The above is an overly simplified case study of the problem I am having. Don't mind the busy wait loop as it would not be used in practice.

Basically I am passing a Task of an unknown structure to a generic package that itself runs a task whose sole job is to monitor the provided task. Apparently since the Generic doesn't know that this is a task, the compiler will not allow me to use the Terminated aspect to learn when it has completed.

Is there a way to hint to the compiler that this is indeed a task object? Or is there an alternative method to determine if the task has terminated?

I suppose the worst case scenario is to pass a protected boolean to the M thread that will set the flag upon any sort of termination. Problem with that strategy is that I don't trust the programmer of the task to do this consistently. So then i'd have to write a task interface, elaborate each of my task types, and pass that to the generic... all because my terminated aspect doesn't work in this context.

Any help is appreciated, thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-23 17:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23 14:20 Using the "Terminated" aspect for a task passed to a generic NiGHTS
2018-04-23 15:40 ` AdaMagica
2018-04-23 16:23 ` Jeffrey R. Carter
2018-04-23 16:29 ` Dmitry A. Kazakov
2018-04-23 16:35 ` Dan'l Miller
2018-04-23 16:41   ` Dmitry A. Kazakov
2018-04-23 17:04   ` Dan'l Miller
2018-04-23 17:18 ` NiGHTS

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