Many threads or as few threads as possible?

前端 未结 5 833
走了就别回头了
走了就别回头了 2020-12-25 08:40

As a side project I\'m currently writing a server for an age-old game I used to play. I\'m trying to make the server as loosely coupled as possible, but I am wondering what

5条回答
  •  失恋的感觉
    2020-12-25 09:20

    use an event stream/queue and a thread pool to maintain the balance; this will adapt better to other machines which may have more or less cores

    in general, many more active threads than you have cores will waste time context-switching

    if your game consists of a lot of short actions, a circular/recycling event queue will give better performance than a fixed number of threads

提交回复
热议问题