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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,853d46c8ab5c7ada,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!newsfeed.stanford.edu!newshub.sdsu.edu!flph200.ffdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!flpi150.ffdc.sbc.com.POSTED!b5cf28ff!not-for-mail From: Dimonax Subject: Protected Adjust? Newsgroups: comp.lang.ada User-Agent: Pan/0.133 (House of Butterflies) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: NNTP-Posting-Host: 75.48.217.250 X-Complaints-To: abuse@prodigy.net X-Trace: flpi150.ffdc.sbc.com 1239954777 ST000 75.48.217.250 (Fri, 17 Apr 2009 03:52:57 EDT) NNTP-Posting-Date: Fri, 17 Apr 2009 03:52:57 EDT Organization: at&t http://my.att.net/ X-UserInfo1: OP[YBXWDLJUURW\[BBHZ_WTAUC\NQOPDLXUNNHXIJYWZUYICD^RAQBKZQTZTX\_I[^G_KGFNON[ZOE_AZNVO^\XGGNTCIRPIJH[@RQKBXLRZ@CD^HKANYVW@RLGEZEJN@\_WZJBNZYYKVIOR]T]MNMG_Z[YVWSCH_Q[GPC_A@CARQVXDSDA^M]@DRVUM@RBM Date: Fri, 17 Apr 2009 07:52:57 GMT Xref: g2news2.google.com comp.lang.ada:5478 Date: 2009-04-17T07:52:57+00:00 List-Id: How does one encapsulate a Controlled type inside a Protected type such that Initialize, Finalize, and Ajust can be done concurrently? Basically I'm locking a Variable into a Cache, and I don't want that variable being copied in and out of the Cache. i.e. Each Task has to be able to operate on the variable in-place. I'm using the low level mlock()/munlock() system calls to create the cache.(Locks the memory to RAM and prevents paging/swapping). So far, I'm thinking this... Pragma Profile(Ravenscar); with Ada.Finalization; --Yeah, this works even with Ravenscar profile. -- package mutators is type Item_Type is tagged null record; type Mutable is new Ada.Finalization.Controlled with private; private type Item_Pointer is access Item_Type; type Mutable is new Ada.Finalization.Controlled with record Mutable_Item : Item_Pointer; end record; -- Catchy type name eh? ;-> -- Protected Type Mutual_Excluder is -- This procedure is called by Initialize -- procedure Create(Item : in Item_Type); -- This procedure is called by Adjust. -- procedure Update(Item : in out Item_Pointer); -- This procedure is called by Finalize -- procedure Destroy(Item : in out Item_Pointer); private Item_Holder : Item_Type; Item_Location : Item_Pointer := Item_Holder'Access; end Mutual_Excluder; procedure Initialize(Mutable_Object : in out Mutable); procedure Adjust(Mutable_Object : in out Mutable); procedure Finalize(Mutable_Object : in out Mutable); end mutators; Should I have the seperate Item_Type and handle that seperately? Or should I just pass the entire Mutable Object in and out of the protected procedures? The goal of this excercise is to be able to use the Adjust procedure from different tasks exclusively. Tips, advice? Freejack