Quantcast
Channel: Photon Server — Photon Engine
Viewing all articles
Browse latest Browse all 1557

Photon SDK multithreading

$
0
0
I am very new to multi threading, so please bare with me... (please correct me if I say something wrong, I am writing how I understand it)

I am building server side game logic using Photon SDK LiteApplication.

From what I understand, every peer runs in its own thread... also every room has its own thread via ThreadFiber API (?)

I have a World object on the server, which is not tied to any specific room, but I need to tick it, so I create thread fiber there and do something like this:

ThreadFiber fiber = new ThreadFiber("Worker Thread");
fiber.ScheduleOnInterval(Tick, 50, 50);

I believe that would also execute on a different thread(?)

How can I ensure thread safety, i,e, if World ticks and updates some data, it does not cause problem if some peer or a room is also trying to read/write data on the same data at the same time?

Is there any API within Photon to facilitate this, or do I need to pretty much place "lock" statements in every function?

Thank you for help.

Viewing all articles
Browse latest Browse all 1557

Trending Articles