Trying to run some multi threaded bit of code and clang llvm compiler complains that std::atomic<double>::compare_exchange_weak()
does not have the correct number of arguments. Can anyone please help?
thanks Amine
static std::atomic<int> counter(0);
std::atomic<double> x = {0.0000000003};
template class std::vector<double>;
struct TestVector
{
std::vector<double> Vect;
explicit TestVector(std::size_t n) : Vect(std::vector<double>(n))
{
for(auto i = 0; i< Vect.size(); ++i)
{
Vect[i] = std::cos(i*M_PI/2.0);
}
}
};
const TestVector Z(30000);
void TestOnAtomics()
{
int j { 0};
double y = (Z.Vect)[j] + 0.00000005;
const double u = 1.22222222;
while(!(x.compare_exchange_weak(y,u)) && j<((Z.Vect).size() - 1))
{
++counter;
x.store(std::move((Z.Vect)[j]), std::memory_order::memory_order_seq_cst);
++j;
std::cout << "\nMy value is " << x << " and that of y is: " << y << "\n";
y = (Z.Vect)[j];
};
}
Aucun commentaire:
Enregistrer un commentaire