Anúncio
Anúncio

Mais conteúdo relacionado

Último(20)

Anúncio

C++20 Atomic std::shared_ptr and std::weak_ptr

  1. Atomic std::shared_ptr and std::weak_ptr
  2. C++20 이전 shared_ptr 과 weak_ptr 의 참조 카운트는 원자적으로 동작하지만 데이터는 그렇지 않았다. 그리고 atomic 에서 shared_ptr 과 weak_ptr 을 지원하지 않았다. error C2338: static_assert failed: 'atomic<T> requires T to be trivially copyable, copy constructible, move constructible, copy assignable, and move assignable.' message : 컴파일되는 클래스 템플릿 인스턴스화 'std::atomic<std::shared_ptr<int>>'에 대한 참조를 확인하세요.
  3. C++20 이후 atomic 헤더가 아닌 memory 헤더파일에 템플릿 특수화로 구현 사용법은 기존 atomic 과 동일
  4. C++20 에 추가된 atomic 함수 wait 알림을 받고 atomic값이 바뀔때까지 스레드 블록 됨 notify_one wait 중인 atomic 오브젝트가 있는 스레드를 하나 깨움 notify_all wait 중인 atomic 오브젝트가 있는 스레드를 전부 깨움
Anúncio