comp.lang.ada
 help / color / mirror / Atom feed
* controlled assignment of nonlimited, monitored types
@ 1997-04-13  0:00 Jonas Nygren
  0 siblings, 0 replies; only message in thread
From: Jonas Nygren @ 1997-04-13  0:00 UTC (permalink / raw)




A question on using Adjust and Finalize controlled 
assignment operations for a nonlimited and monitored
type.

I have implemented a small stack-family of packages:

	Stack_G.{Bounded_G,Unbounded_G,Monitored_G}

Stack_G.Monitored_G can be instantiated with either Bounded_G
or Unbounded_G. The monitored stack type is derived from the
abstract stack type (in Stack_G).

The stack type is extended with a monitor in the following way:

   type Monitor_GC is new Ada.Finalization.Controlled with
      record
         Ref : Monitor_Ref := new Monitors.Monitor_Type;
      end record;

   type Stack_Type is new Some_Stack_Type with
      record
         Monitor : Monitor_GC;
      end record;

The monitor provides sychronization operations which can be used
in the stack subprograms to make them task safe.

The question is if it is really possible to have assignments for
such a nonlimited monitored type. To me it does not seem possible
since the assignment (Finalize followed by Adjust) leaves a small
gap when the state of the object being assigned to is 'undefined'.

It is possible to add a write-lock in Finalize for Stack_Type but
in the process of finalization the monitor must be deleted and a
new monitor allocated. If some other task were to wait on an 
entry in the monitor that is freed it will have some sort of
tasking error, which is not very nice.

It seems I lack sufficient understanding to sort this out so I
am out looking for a definite answer or some pointers to some
sample code where something similar has been implemented.

Is it possible to make a construct, such as described above, task-safe?

/jonas

PS Yes, I know that the solution is to make the type limited but this
   also requires that all the stack types must be made limited too,
   which I would like to avoid if possible. DS 




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-04-13  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-13  0:00 controlled assignment of nonlimited, monitored types Jonas Nygren

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