securise dt_dev_distort_* fct accros threads

To summarize the problem, dt_dev_distort_transform (and backtransform) need to crawl through each enabled iop and apply the distortion transformations.
The problem is that the access is not thread safe, as the pipe can be in a intermediate state.
For example it can be in the middle of a resynchronisation : all nodes reseted, and the history not already applied.
To avoid that I've tried to add another mutex, to know if the pipe is synchronized with the history or not.

Please review very carefully as it's the first time I touch to threading system in dt. Thanks

example of step by step to see a problem : 
- apply a "distort" iop (for ex crop the image)
- add a clone circle
- zoom in the image (to augment the effect)
- change the size of the spot with mouse scroll.
at some point, you may see that the spot position "jump"
It can be done with all "on canvas" draw (gnd, masks,...). it's just an example, to easy trigger the bug