강의

멘토링

커뮤니티

Inflearn Community Q&A

wlsrb01477614's profile image
wlsrb01477614

asked

[MMORPG Game Development with C++ and Unreal Series] Part 4: Game Server

Lock-Free Stack #3

Lock-Free Stack #3 compare_exchange_strong 사용이유

Written on

·

306

0

void IncreaseHeadCount(CountedNodePtr& oldCounter)
{
    while (true)
    {
        CountedNodePtr newCounter = oldCounter;
        ++newCounter.externalCount;

        // 카운터가 정상적으로 1 증가할때까지 실행
        if (_head.compare_exchange_strong(oldCounter,newCounter))
        {
            oldCounter.externalCount = newCounter.externalCount;
            break;
        }
    }
}

 

while의 조건문에는 언제나 compare_exchange_weak를 사용했는데
while문 내부의 if에는 compare_exchange_strong을 사용한 이유가 궁금합니다.

 

네트워크MMORPGwindows-server

Answer 1

0

Rookiss님의 프로필 이미지
Rookiss
Instructor

임베디드가 아닌 대부분의 환경에선 strong, weak 무엇으로 해도 동일합니다.

wlsrb01477614님의 프로필 이미지
wlsrb01477614
Questioner

특별한 의미는 없는거였군요
감사합니다

wlsrb01477614's profile image
wlsrb01477614

asked

Ask a question