CPitBoss Class Reference

class CPitBoss
The PitBoss has responsibility for global resources and gross error handling (panics, etc). The Pit Boss thread must be started by the Configurator before any worker threads. The ESock instance loading it must be the only one having the WorkerId 0 (TWorkerThreadInfo::EMainThread). The PitBoss has two main responsibilities:
  1. Maintain global data structures, accessible to all Workers to which the PitBoss pointer is published (through the TWorkerMainIntroductionMsg). Mostly the workers will access this data using PitBoss access functions which are thread-safe, taking special measures to guarantee this where needed.

  2. Manage Worker thread start and death: Registering Workers and installing protocols when they start and do a best effort cleanup if they die due to some error condition.

Apart from these, the PitBoss also provides some minor but important services. For example as all ESock instances can have their own heap sometimes it happens that one Worker needs to do something that might cause allocation or freeing on another workers heap, such as inserting a sub-session into a Dealers session. So the PitBoss offer a function that can determine whether a different heap is needed (maybe the two workers have different heaps, maybe they share one heap) and does the switch. It also has AddSubSession() and RemoveSubSession() methods used by the Player, assuring this happens on the right heap for operations like Socket Transfers.