comp.lang.ada
 help / color / mirror / Atom feed
* Equivalent to C++'s 'this' for tasks?
@ 1997-05-21  0:00 Dale Stanbrough
  1997-05-22  0:00 ` Robert I. Eachus
  1997-05-22  0:00 ` Dale Stanbrough
  0 siblings, 2 replies; 4+ messages in thread
From: Dale Stanbrough @ 1997-05-21  0:00 UTC (permalink / raw)



If I wanted to create a task...

	task type a;
	task type a_ptr is access all task;
	
	task type a;
	
would it be possible in the body of a to construct/obtain
a pointer to the task?

Something like...

	task body a is
	   me : a_ptr;
	begin
	   me := ???'{Unchecked_}Access;
	
	end;

You could then pass this information around and let other
parts of the program query this object as to its state, or
would I have to allocate the object dynamically and hand it
the access value as part of an initialisation entry?


Dale




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

* Re: Equivalent to C++'s 'this' for tasks?
  1997-05-21  0:00 Equivalent to C++'s 'this' for tasks? Dale Stanbrough
@ 1997-05-22  0:00 ` Robert I. Eachus
  1997-05-22  0:00 ` Dale Stanbrough
  1 sibling, 0 replies; 4+ messages in thread
From: Robert I. Eachus @ 1997-05-22  0:00 UTC (permalink / raw)



In article <5ltfe8$edr$1@goanna.cs.rmit.edu.au> Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU> writes:

  > If I wanted to create a task...

  > would it be possible in the body of a to construct/obtain
  > a pointer to the task?

   See C.7.1, package Ada.Task_Identification.  If the Ada compiler
you are using doesn't provide this package (it is in the Systems
Programming Annex), then there are other messier solutions.

   However, since this package isn't all that hard to implement, I
suspect that even with an Ada 83 compiler the easiest solution is to
build it yourself.  (You will probably have to look at some
disassembled code to find the right run-time calls if the compiler
implementor doesn't provide that documenation.)

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




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

* Re: Equivalent to C++'s 'this' for tasks?
  1997-05-21  0:00 Equivalent to C++'s 'this' for tasks? Dale Stanbrough
  1997-05-22  0:00 ` Robert I. Eachus
@ 1997-05-22  0:00 ` Dale Stanbrough
  1997-05-23  0:00   ` Robert A Duff
  1 sibling, 1 reply; 4+ messages in thread
From: Dale Stanbrough @ 1997-05-22  0:00 UTC (permalink / raw)



Robert I. Eachus writes:

"   See C.7.1, package Ada.Task_Identification.  If the Ada compiler
 you are using doesn't provide this package (it is in the Systems
 Programming Annex), then there are other messier solutions.
 
    However, since this package isn't all that hard to implement, I
 suspect that even with an Ada 83 compiler the easiest solution is to
 build it yourself.  (You will probably have to look at some
 disassembled code to find the right run-time calls if the compiler
 implementor doesn't provide that documenation.)"


No, this won't do at all. There is no way to make entry calls from a
task id, so how could the objects that are passed this id query the
state of the task?

I would like something that doesn't require delving into stuff that
the rationale claims is mainly used for building scheduling systems.


Dale




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

* Re: Equivalent to C++'s 'this' for tasks?
  1997-05-22  0:00 ` Dale Stanbrough
@ 1997-05-23  0:00   ` Robert A Duff
  0 siblings, 0 replies; 4+ messages in thread
From: Robert A Duff @ 1997-05-23  0:00 UTC (permalink / raw)



In article <5m2elp$ii4$1@goanna.cs.rmit.edu.au>,
Dale Stanbrough  <dale@goanna.cs.rmit.EDU.AU> wrote:
>I would like something that doesn't require delving into stuff that
>the rationale claims is mainly used for building scheduling systems.

Within a type, the type name refers to the "current instance" of that
type, sort of like "this" or "self" in some other languages.  So, within
a task body for task type T, T refers to the currently running task.  So
you can say "T'Unchecked_Access" and pass that access value around and
so forth.  This only works for *limited* types, such as tasks, because
the current instance is defined to be aliased only for limited types.
And because of the accessibility rules, it has to be 'Unchecked_Access,
rather than 'Access -- this is because you might create a task of type T
within a more-nested procedure -- the "Unchecked_" is supposed to warn
you of this potential for dangling pointers.

To read about this stuff, look up "current instance", "aliased", and
"accessibility level" in the index of the RM.

- Bob




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

end of thread, other threads:[~1997-05-23  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-21  0:00 Equivalent to C++'s 'this' for tasks? Dale Stanbrough
1997-05-22  0:00 ` Robert I. Eachus
1997-05-22  0:00 ` Dale Stanbrough
1997-05-23  0:00   ` Robert A Duff

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