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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,df3ae8b6de1dbeaa,start X-Google-Attributes: gid103376,public From: "Jonas Nygren" Subject: controlled assignment of nonlimited, monitored types Date: 1997/04/13 Message-ID: <01bc481f$e5757f00$829d6482@joy.ericsson.se>#1/1 X-Deja-AN: 234531191 Organization: Ericsson Newsgroups: comp.lang.ada Date: 1997-04-13T00:00:00+00:00 List-Id: 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