viewimage.php?id=2ab4c42ef0d0&no=24b0d769e1d32ca73ced83fa11d0283109f613b0c2e59fad7a6296a8113282d7b82f75d12ca0c8f1cab472619c781c64da657657302ae68ac5bd7ae8041d115f3722


Atomically compares the object representation (until C++20)value representation (since C++20) of the object pointed to by obj with that of the object pointed to by expected, and if those are bitwise-equal, replaces the former with desired (performs read-modify-write operation). Otherwise, loads the actual value pointed to by obj into *expected (performs load operation). Copying is performed as if by std::memcpy.



viewimage.php?id=2ab4c42ef0d0&no=24b0d769e1d32ca73ced83fa11d0283109f613b0c2e59fad7a6296a8113282d7b82f75d12ca0c8f1cab472619c781c64da657657302aead992b378e05618115fa2ef



이 함수 작동이  obj가 가리키는 것과 expected가 가리키는 것이 동일해야하고 (헤드 스마트 포인터 == 삽입한 새 노드의 next 스마트 포인터여야 함, 다른 스레드에서 다시 헤드를 이동시켰을 수도 있어서)

만약 동일하다면 desired를 obj쪽에 복사하고 (헤드 포인터가 새 노드를 가리키게 함)

동일하지 않다면 expected쪽을 업데이트해서 obj가 가리키는 것과 동일한 것을 가리키게 한다 (남이 헤드를 이동시켜놨다면 새 노드의 넥스트 포인터도 똑같이 옮겨준다) -> 이후 재시도 위해 루프 필요


내가 이해한게 맞음???


구린 디자인이라던데 함수 자체가 헷갈려서 질문함