Multi-thread use in photon

Options
Idrakis
edited November 2011 in Photon Server
Hello,

Are the IPeer.OnOperationRequest execut in multi-threads on the server ?
It's to know if it's safe to share datas between the different peer, or if i should lock datas when i access them.

Thank you.

Comments

  • dreamora
    Options
    there are aspects in its related deeper handling thats parallel yes and thats safe, it uses the fibers
  • Tobias
    Options
    The peer OnOperationRequest is thread-safe per peer but to make it perform better, multiple peers are run parallel!
    So access from one peer to another should be done via messages/fibers as well.

    If you need a number of clients to modify the same object you can possibly do this by using rooms. In the Lite application, peers will forward some Operations to their room via another message. The room itself is handling these messages sequenced and in a thread safe manner. Operations in a room might change objects which several peers need access to.

    Rooms in turn have to avoid modifying other rooms directly.
  • How do you decide if OnOperationRequest is multithreaded ? Is it automatic or do you have to set the number of thread you wish somewhere ?
  • dreamora
    Options
    Its automatic, the total number of threads used on a photon application is configured in the config file within the instance configurations

    best read the documentation on how to configure photon to learn more about it
  • Thank you dreamora !