In my turn based game, I want each player, when it is his turn, to have a timeout to play.
What is the best way to implement it?
A scheduler in each room? (possible many rooms?)
A scheduler which run every second to loop every room for timeout checking? (many runs)
A timer at the client side? (the logic is at the client? The client sends timeout message to the server?)
Is there other better solution?
Thank you.
Turn based game player timeout
Indeed. Runnable tasks do not however get their own thread. They're executed as their delays are triggered. During which time, they occupy one of the threads in the pool. Once they're done, they are taken off that thread, and another takes its place.
The documentation refers to resizeThreadPool, where you can adjust the number of threads the pool has. As it says, normally 1-4 threads is more than enough and avoids penalty from excessive context switching.
It is possible to saturate all threads if you have too many long-duration events. In which case, you should break them up OR increase the number of threads. But this is rare, and you should probably use another thread pool for those types of tasks if encountered.
The documentation refers to resizeThreadPool, where you can adjust the number of threads the pool has. As it says, normally 1-4 threads is more than enough and avoids penalty from excessive context switching.
It is possible to saturate all threads if you have too many long-duration events. In which case, you should break them up OR increase the number of threads. But this is rare, and you should probably use another thread pool for those types of tasks if encountered.
Who is online
Users browsing this forum: No registered users and 53 guests