Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: To standardize Boost.Pool

Reply
Thread Tools

Re: To standardize Boost.Pool

 
 
Jorgen Grahn
Guest
Posts: n/a
 
      04-12-2011
[I skip the c.l.c++.moderated crosspost]

On Tue, 2011-04-12, Phil Bouchard wrote:
>
> Boost.Pool provides an is_from() member function that does a simple
> range checks of the heap memory pages and returns whether a pointer is
> part of the pool or not. This is a very useful function which I think
> should be part of the standards because it could be used for the global
> pool as well; i.e. the one used by operator ::new and ::delete. The
> benefits for memory management of knowing whether an object resides on
> the heap or stack outweigh the costs of having to pollute the global
> namespace.


What would those benefits be, according to you? Detecting bugs (e.g.
assert_on_heap(ptr)), or something else?

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
 
Öö Tiib
Guest
Posts: n/a
 
      04-13-2011
On Apr 13, 10:08*am, Phil Bouchard <(E-Mail Removed)> wrote:
> On 4/12/2011 5:31 PM, Phil Bouchard wrote:
>
> > On 4/12/2011 2:56 PM, Jorgen Grahn wrote:

>
> >> What would those benefits be, according to you? Detecting bugs (e.g.
> >> assert_on_heap(ptr)), or something else?

>
> > Garbage collectors make use of such a function but also another memory
> > manager I wrote called: Shifted Pointer where we can see a repetitive
> > use of the function is_from() here:
> >http://www.fornux.com/personal/phili...tr/boost/shift...

>
> After some discussion with Boost, contiguous memory pool objects could
> represent the process' stack, data and heap segments legally. *For example:
>
> struct process
> {
> * * * * static pool data;
> * * * * static pool heap;
> * * * * static pool stack;
>
> };
>
> The default implementation of the global operator ::new could be:
>
> void * operator new(size_t n) { return process::heap.malloc(n); }
>
> A call to is_from() with a pointer guaranteed to be within one of the 3
> pools will then be valid:
>
> int * h = new int;
> process::heap.is_from(h) // true
> int s;
> process::heap.is_from(& s) // false
> process::stack.is_from(& s) // true
> static int d;
> process::heap.is_from(& d) // false
> process::stack.is_from(& d) // false
> process::data.is_from(& d) // true


Please elaborate what is process::stack? On most platforms a process
may have several threads, number of these threads often changes
dynamically during processes lifetime and each of these threads does
have its own stack.
 
Reply With Quote
 
 
 
 
Miles Bader
Guest
Posts: n/a
 
      04-14-2011
Phil Bouchard <(E-Mail Removed)> writes:
> My apologies but I forgot mentioning that we wouldn't want if_from to
> get discredited before it upgrades to the standards. We are looking for
> both a standard compliant version of is_from and a system specific
> version of it.


BTW, the name "is_from" seems very odd -- "foo->is_from (ptr)" _looks_
like it should ask the question "foo is from ptr?", but really it means
the opposite ("ptr is from foo?").

A better name might be "contains": foo->contains (ptr)

-miles

--
Twice, adv. Once too often.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Industry tries to standardize DVD format. Allan DVD Video 0 04-15-2005 05:51 PM
libxml needs to be tamed (standardize C/C++ XML library?) Generic Usenet Account C Programming 3 06-08-2004 02:36 PM
libxml needs to be tamed (standardize C/C++ XML library?) Generic Usenet Account XML 3 06-08-2004 02:36 PM
Time to standardize the XML library for C/C++ Kong Bhat C++ 17 04-13-2004 05:49 AM
Time to standardize the XML library for C/C++ Kong Bhat C Programming 6 04-08-2004 02:44 PM



Advertisments