comp.lang.ada
 help / color / mirror / Atom feed
* Re: Q:Usage of storage Pools
       [not found] <jcamq-v1p.ln1@boavista.snafu.de>
@ 2003-05-31 20:23 ` Robert A Duff
  2003-05-31 20:50   ` Michael Erdmann
  0 siblings, 1 reply; 6+ messages in thread
From: Robert A Duff @ 2003-05-31 20:23 UTC (permalink / raw)


Michael Erdmann <michael.erdmann@snafu.de> writes:

> Hallo all,
> 
> i am trying to use storage pools, and i have come to a blocking 
> point. The construct below failes to compile with GNAT:
> 
> with Pool;
> 
> package List is
> 
>    type List_Element_Type;
>    type List_Element_Access is access List_Element_Type;
> 
>    type List_Element_Type is record
>           Next : List_Element_Access := null;
>        end record;
> 
>    package Element_Pool is new Pool( Pool_Data_Type => List_Element_Type );
> 
>    Storage : Element_Pool.Object;
>    for List_Element_Access'Storage_Pool use Storage;
> 
> end List;
> 
> with the error 
> 
> gnatmake test.adb -o testx
> gcc -c test.adb
> list.ads:12:04: warning: no more representation items for type 
> "List_Element_Access" defined at line 6
> list.ads:15:04: representation item appears too late
> gnatmake: "test.adb" compilation error
> 
> I have played arround with various locations of the for statement
> but is does not help.

You can't put the "for..." after a generic instantiation.
You can't put it before the instantiation, since it refers
to the instance.

Why do you want to pass the type into the pool generic like that?
To know its size and alignment?

You might be able to pass this info to the pool as discriminants,
instead.

- Bob



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

* Re: Q:Usage of storage Pools
  2003-05-31 20:23 ` Q:Usage of storage Pools Robert A Duff
@ 2003-05-31 20:50   ` Michael Erdmann
  2003-05-31 23:55     ` Robert A Duff
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Erdmann @ 2003-05-31 20:50 UTC (permalink / raw)


Robert A Duff wrote:
> Michael Erdmann <michael.erdmann@snafu.de> writes:
> 
.................
>>
>>package List is
>>
>>   type List_Element_Type;
>>   type List_Element_Access is access List_Element_Type;
>>
>>   type List_Element_Type is record
>>          Next : List_Element_Access := null;
>>       end record;
>>
>>   package Element_Pool is new Pool( Pool_Data_Type => List_Element_Type );
>>
>>   Storage : Element_Pool.Object;
>>   for List_Element_Access'Storage_Pool use Storage;
>>
>>end List;
>>
>>with the error 
.......................
> 
> 
> You can't put the "for..." after a generic instantiation.
> You can't put it before the instantiation, since it refers
> to the instance.
> 
> Why do you want to pass the type into the pool generic like that?
> To know its size and alignment?
I simply want to store a list nodes of one kine in a special
memory pool with special features.

> 
> You might be able to pass this info to the pool as discriminants,
> instead.
> 
> - Bob




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

* Re: Q:Usage of storage Pools
  2003-05-31 20:50   ` Michael Erdmann
@ 2003-05-31 23:55     ` Robert A Duff
  2003-06-01  6:55       ` Michael Erdmann
  0 siblings, 1 reply; 6+ messages in thread
From: Robert A Duff @ 2003-05-31 23:55 UTC (permalink / raw)


Michael Erdmann <michael.erdmann@snafu.de> writes:

> I simply want to store a list nodes of one kine in a special
> memory pool with special features.

You mean, like a free list?
Maybe you shouldn't use storage pools at all.
Just declare a function in the generic that returns an element
of the free list?

- Bob



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

* Re: Q:Usage of storage Pools
  2003-05-31 23:55     ` Robert A Duff
@ 2003-06-01  6:55       ` Michael Erdmann
  2003-06-01  8:05         ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Erdmann @ 2003-06-01  6:55 UTC (permalink / raw)


Robert A Duff wrote:
> Michael Erdmann <michael.erdmann@snafu.de> writes:
> 
> 
>>I simply want to store a list nodes of one kine in a special
>>memory pool with special features.
> 
> 
> You mean, like a free list?
No, the list structure you have seen is something which i like
to allocate in the pool.

> Maybe you shouldn't use storage pools at all.
The reason why i am using a pool is because i like to control
the behaviour of the pool it self.

> Just declare a function in the generic that returns an element
> of the free list?

The idea is to achieve some kind of object persistency by writing
out all objects allocated in the pool when the program is forced to
terminate. Additionally the pool is going to be located in a certain
pice of shared memory.

Since the pool knows the sturcture of the objects to be stored
there he is able to derefernce the pointers like Next when wiriting
it into a file.

Michael


> 
> - Bob




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

* Re: Q:Usage of storage Pools
  2003-06-01  6:55       ` Michael Erdmann
@ 2003-06-01  8:05         ` Simon Wright
  2003-06-02 19:28           ` Michael Erdmann
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Wright @ 2003-06-01  8:05 UTC (permalink / raw)


Michael Erdmann <michael.erdmann@snafu.de> writes:

> Since the pool knows the sturcture of the objects to be stored there
> he is able to derefernce the pointers like Next when wiriting it
> into a file.

This is a very clever pool!

The BCs do this by passing the pool as a generic parameter:

generic
   Storage : in out System.Storage_Pools.Root_Storage_Pool'Class;
package BC.Containers.Collections.Unbounded is



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

* Re: Q:Usage of storage Pools
  2003-06-01  8:05         ` Simon Wright
@ 2003-06-02 19:28           ` Michael Erdmann
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Erdmann @ 2003-06-02 19:28 UTC (permalink / raw)


Simon Wright wrote:
> Michael Erdmann <michael.erdmann@snafu.de> writes:
> 
> 
>>Since the pool knows the sturcture of the objects to be stored there
>>he is able to derefernce the pointers like Next when wiriting it
>>into a file.
> 
> 
> This is a very clever pool!

I will publish the software after it has been tested.

> 
> The BCs do this by passing the pool as a generic parameter:
> 
> generic
>    Storage : in out System.Storage_Pools.Root_Storage_Pool'Class;
> package BC.Containers.Collections.Unbounded is





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

end of thread, other threads:[~2003-06-02 19:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <jcamq-v1p.ln1@boavista.snafu.de>
2003-05-31 20:23 ` Q:Usage of storage Pools Robert A Duff
2003-05-31 20:50   ` Michael Erdmann
2003-05-31 23:55     ` Robert A Duff
2003-06-01  6:55       ` Michael Erdmann
2003-06-01  8:05         ` Simon Wright
2003-06-02 19:28           ` Michael Erdmann

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