Error compile c++ in xcode

Hi everyone,

I got an error when compile c++ with xcode 13.


> 'notify_one' is unavailable
'wait' is unavailable


This is my code in main.mm :

#include <iostream>
#include <atomic>
#include <thread>

std::atomic_flag condAtomicFlag{};

std::atomic<int> counter{};
constexpr int countlimit = 1000000;

void ping() {
  while(counter <= countlimit) {
    condAtomicFlag.clear();
    condAtomicFlag.test_and_set();
     
    ++counter;
     
    condAtomicFlag.notify_one();
  }
}

void pong() {
  while(counter < countlimit) {
    condAtomicFlag.wait(false);
    condAtomicFlag.clear();
    condAtomicFlag.notify_one();
  }
}

int main() {

   auto start = std::chrono::system_clock::now();

   
  condAtomicFlag.test_and_set();
  std::thread t1(ping);
  std::thread t2(pong);

  t1.join();
  t2.join();

  std::chrono::duration<double> dur = std::chrono::system_clock::now() - start;
  std::cout << "Duration: " << dur.count() << " seconds" << std::endl;

}

I researched and found Apple clang not support "notify_one" and "wait" function

If have any solution for my issue

Thank you

Error compile c&#43;&#43; in xcode
 
 
Q