Consider using boost::atomic or boost::lockfree for multithreaded atomic operations
C++11 provides language-level support for this, but boost::atomic provides a portable way to accomplish this.
Also look at boost::lockfree, which implements a lock-free queue and lock-free stack.
See also James_Research_Group/SpatialOps#15
This should be done after finishing merge !1