Boost logo

Geometry :

Subject: Re: [geometry] volatile polygon
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2013-11-25 17:12:52


On 25 November 2013 12:13, Adam Wulkiewicz <adam.wulkiewicz_at_[hidden]> wrote:
> Long Guo wrote:
>>
>> Dear sir,
>>
>> I have two threads using the same polygon.
>> One thread is modifying the polygon.
>> And I want the other thread to use the modified polygon,
>> so I need to define the polygon as volatile.
>> However, when I use *(volatile polygon*)&mypolygon,
>> I get some error as follows:
>> error: no type named ‘type’ in ‘struct boost::geometry::dimension<volatile
>> boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>
>> > >’.
>>
>> What's wrong with this usage?
>>
>
> boost::geometry::dimension (probably as well as some other functions) isn't
> volatile-aware. Barend maybe we should use remove_volatile<> as well?.
>
> Still, using 'volatile' isn't a proper way of synchronizing data between
> threads.

Neither it guarantees any atomic R/W or injects any memory barriers.

> class producer_thread
> [...]

I'd suggest to take a look at std::future and switch from thread-based
mindset to task-based
programming.

But, digging it deep may be off-topic here.

Best regards,

-- 
Mateusz  Loskot, http://mateusz.loskot.net

Geometry list run by mateusz at loskot.net