From: Dimonax <dimonax@nospam.net>
Subject: Protected Adjust?
Date: Fri, 17 Apr 2009 07:52:57 GMT
Date: 2009-04-17T07:52:57+00:00 [thread overview]
Message-ID: <tzWFl.14725$hc1.6142@flpi150.ffdc.sbc.com> (raw)
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
next reply other threads:[~2009-04-17 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 7:52 Dimonax [this message]
2009-04-17 8:40 ` Protected Adjust? Dmitry A. Kazakov
2009-04-17 18:21 ` sjw
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox