Skip to content

Thread Model

boyism80 edited this page Jul 3, 2026 · 1 revision

Thread Model

Thread Architecture

Within each Game process:

  • I/O threads handle socket read/write (boost::asio).
  • Logic threads run game handlers, map updates, and Lua.
  • Received packets are dispatched from I/O to the logic thread that owns the session's map; responses go back through I/O.

Map-to-thread assignment

Maps are bound to logic threads by map ID:

logic_thread = map.id % N   // N = number of logic threads

All objects on the same map run on the same logic thread, avoiding locks between nearby objects.

Trade-offs

Uneven map distribution can overload a single logic thread. Communication between maps on different threads is more complex than within a single map. I/O and logic thread counts are configurable in the server config file.

An additional AMQP thread handles RabbitMQ consume/publish (not shown in the diagram).

Related pages

Clone this wiki locally