comp.lang.ada
 help / color / mirror / Atom feed
From: NiGHTS <nights@unku.us>
Subject: Using the "Terminated" aspect for a task passed to a generic
Date: Mon, 23 Apr 2018 07:20:31 -0700 (PDT)
Date: 2018-04-23T07:20:31-07:00	[thread overview]
Message-ID: <f2cc5db4-1abf-4a4c-92ed-089e0e7d6d21@googlegroups.com> (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!

             reply	other threads:[~2018-04-23 14:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 14:20 NiGHTS [this message]
2018-04-23 15:40 ` Using the "Terminated" aspect for a task passed to a generic 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
replies disabled

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