Question about race condition of room's custom property

Options

I want to check all players are successfully loaded when scene changed. So I use room custom property.

If a client has loaded a scene, he/she do something like this :

int count = (int)PhotonNetwork.CurrentRoom.CustomProperty["playerCount"];

PhotonNetwork.CurrentRoom.SetCustomProperty("playerCount", count+1);


I want to know that is there any race condition while call 'SetCustomProperty' and sending messages about updated value to other players?


https://doc.photonengine.com/en-us/server/current/reference/faq#how_to_avoid_race_conditions_and_other_multithreading_issues_

I have already read this document's race condition section. But i'm not sure that it says there's no race condition in a scenario like above

Best Answer

  • JohnTube
    JohnTube ✭✭✭✭✭
    Answer ✓
    Options

    Hi @presentlee,

    Thank you for choosing Photon!

    That documentation link you posted is about Photon Server product (self-hosted SDK) and not about PUN. While you can use PUN with self-hosted Photon Server, what you are looking for is not threading but instead CAS: Check-And-Swap or Compare-And-Set feature.

    Read more here.

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Answer ✓
    Options

    Hi @presentlee,

    Thank you for choosing Photon!

    That documentation link you posted is about Photon Server product (self-hosted SDK) and not about PUN. While you can use PUN with self-hosted Photon Server, what you are looking for is not threading but instead CAS: Check-And-Swap or Compare-And-Set feature.

    Read more here.

  • Thank you for your help!