void operator()(const range_t& range) const { util::rng the_rng(range.begin()); const size_t i_end = range.end(); size_t count = 0; #if USECONCVEC points.grow_to_at_least(i_end); #else // Locked enlarge to a not thread-safe STD::VECTOR grow_vector_to_at_least(pushBackMutex,points,i_end); #endif // USECONCVEC for(size_t i = range.begin(); i != i_end; ++i) { points[i]=util::GenerateRNDPoint<double>(count,the_rng,util::rng::max_rand); } }
void operator()(const range_t& range) const { util::rng the_rng(range.begin()); const size_t i_end = range.end(); size_t count = 0, j = 0; point_t tmp_vec[grainSize]; for(size_t i=range.begin(); i!=i_end; ++i) { tmp_vec[j++] = util::GenerateRNDPoint<double>(count,the_rng,util::rng::max_rand); } #if USECONCVEC grow_vector_to_at_least(points,range.end()); #else // USE STD::VECTOR grow_vector_to_at_least(insertMutex,points,range.end()); #endif // USECONCVEC std::copy(tmp_vec, tmp_vec+j,points.begin()+range.begin()); }
void operator()(const range_t& range) const { util::rng the_rng(range.begin()); const size_t i_end = range.end(); size_t count = 0, j = 0; point_t tmp_vec[grainSize]; for(size_t i=range.begin(); i!=i_end; ++i) { tmp_vec[j++] = util::GenerateRNDPoint<double>(count, the_rng, util::rng::max_rand); } //Here we have race condition. Elements being written to may be still under construction. //For C++ 2003 it is workarounded by vector element type which default constructor does not touch memory, //it being constructed on. See comments near default ctor of point class for more details. //Strictly speaking it is UB. //TODO: need to find more reliable/correct way points.grow_to_at_least(range.end()); std::copy(tmp_vec, tmp_vec+j,points.begin()+range.begin()); }