Boost logo

Boost Users :

Subject: Re: [Boost-users] [variant] variant member function apply_visitor( visitor ) thread-safe?
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2008-09-08 11:20:00


Hicham,

my only concern would be to evaluate how the variant behaves in MT
environment. Especially if the implementation uses VTable idiom to avoid
additional level of indirection. In that case if you instantiate variants
containing the same type from 2 threads at a time it might get into race
condition. VTable in Variants was described in the article by Andrei
Alexandrescu on how to implement discriminated unions (published in DDJ) and
he suggested to use VTable to avoid additional indirection for the sake of
performance.

Here are the links:
http://www.ddj.com/cpp/184403821
http://www.ddj.com/cpp/184403828
http://www.ddj.com/cpp/184403834

Would be really interesting to get an answer from developers and a doc
statement, on which MT guarantees boost::variant provides.

Best Regards,
Ovanes

On Mon, Sep 8, 2008 at 4:48 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:

> AMDG
>
> Hicham Mouline wrote:
>
>> Is the apply_visitor() method per se thread-safe, meaning,
>> if i have variant object, and i visit it from different threads at same
>> time,
>> and if i assume the visitor i write is thread-safe, my question is about
>> the machinery of apply_visitor() itself, is it thread-safe?
>>
>>
>
> The apply_visitor function itself does not modify the
> variant in any way, such usage ought to be thread-safe.
>
> In Christ,
> Steven Watanabe
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net