Re: [boost] [xint] Boost.XInt formal review (concrete complaint)

----- "Chad Nelson" <chad.thecomfychair@gmail.com> a écrit :
On Mon, 07 Mar 2011 09:45:02 +0100 Ivan Le Lann <ivan.lelann@free.fr> wrote:
I don't think that this is enough to prevent surprises. If someone does
thread t( f, x );
where x is an integer, the thread would receive a shared copy of x. The user would need to explicitly call the copy constructor with a second argument of true to avoid that.
You'd think so, but so long as that thread class takes the integer parameter as either a constant reference or by value, or is the only one thread accessing it if it's passed by non-constant reference, that's not the case.
I'm not sure I understand why you say that t does not get a shared copy. Anyway what seemed obvious to me with current impl is that block below can either leak or double destruct x data. Am I wrong?
void f (integer) {} // by value ... { integer x = 42; async ( f, x ); async ( f, x ); }
(snip)
Unless you explicitly tell the library to use CoW on external objects, it will deep-copy them, so each call to async will get its own storage.
Ohhh ... I only get now what you meant with "external objects". I forgot you have only limited COW. Sorry for my slow brain. This might explain why XInt was significantly faster when I added byref arguments. I exspected marginal speedup and got 30%. Ivan

On Mon, 7 Mar 2011 18:24:42 +0100 (CET) Ivan Le Lann <ivan.lelann@free.fr> wrote:
(snip)
Unless you explicitly tell the library to use CoW on external objects, it will deep-copy them, so each call to async will get its own storage.
Ohhh ... I only get now what you meant with "external objects". I forgot you have only limited COW. Sorry for my slow brain.
This might explain why XInt was significantly faster when I added byref arguments. I exspected marginal speedup and got 30%.
Probably so. I've just finished that change myself (slow today, I took several hours away from the computer for a change). I've found an internal class that might need to be move-enabled before I try running the CoW/move tests, so I probably won't have a chance to finish them tonight. -- Chad Nelson Oak Circle Software, Inc. * * *
participants (2)
-
Chad Nelson
-
Ivan Le Lann