Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-07-20 21:50:27


"Eric Friedman" <ebf_at_[hidden]> wrote in message
news:000501c2305a$b06f0190$a600a8c0_at_eric...
[on thread safety]
> (2) Static member object.
>
> This is problematic because it means a variant cannot be safely used in
> other global static objects.
>
>
> (3) Local static object.
>
> Thread safety primitives are needed because the behavior of a local
> static object is undefined in a multithreaded environment; accordingly,
> thread-safety primitives are required so that access to the object is
> serialized.

The problem occurs only with static variables that are dynamically
initialized. Static variables that are initialized with static constants are
immune to any threading issues. My first Variant code used dynamic
initialization, but the code with the latest column uses only static
initialization - and implements constant-time visitation, conversions etc.

> So I guess cascading-if's (and O(N) complexity) are the way to go for
> now. And maybe compiler optimizations will make the issue moot anyway.

I believe the conclusion above is false. Changing gears, past experience
suggests that the theshold between cascading if's and vcall is 3ish.

It's good to see there's work being done on implementing Variant, and I
would have been glad to participate to that.

Andrei


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk