Subject: Re: [geometry] volatile polygon
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2013-11-25 07:13:53
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
> > >.
> 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. For better ways see:
You should for example use Mutex to synchronize access. This way you
could secure just some operations like operator access, copying of the
polygon or moving (in the case of exclusive ownership).
Some general solution would look like this:
// your thread body
// some code...
// modification of the local copy of polygon
// copying/moving of local to shared
m_poly = boost::move(local_poly);
Then you can run the thread:
and copy/move polygon to the current thread:
polygon p = producer.get_poly();
Geometry list run by mateusz at loskot.net