Ejemplo n.º 1
0
AOSContextManager::AOSContextManager(AOSServices& services) :
  m_Services(services),
  m_History(new ASync_CriticalSection()),
  m_ErrorHistory(new ASync_CriticalSection()),
  m_FreeStore(new ASync_CriticalSectionSpinLock())
{
  m_HistoryMaxSize = services.useConfiguration().useConfigRoot().getInt("/config/server/context-manager/history-maxsize", 100);
  m_ErrorHistoryMaxSize = services.useConfiguration().useConfigRoot().getInt("/config/server/context-manager/error-history-maxsize", 100);
  m_DefaultEventLogLevel = services.useConfiguration().useConfigRoot().getInt("/config/server/context-manager/log-level", 2);
  AASSERT(this, m_DefaultEventLogLevel >= AEventVisitor::EL_NONE && m_DefaultEventLogLevel <= AEventVisitor::EL_DEBUG);
  m_FreeStoreMaxSize = services.useConfiguration().useConfigRoot().getInt("/config/server/context-manager/freestore/max-size", 500);
  size_t freeStoreInitialSize = services.useConfiguration().useConfigRoot().getInt("/config/server/context-manager/freestore/initial-size", 100);
  AASSERT(this, freeStoreInitialSize <= m_FreeStoreMaxSize && freeStoreInitialSize >= 0);

  m_Queues.resize(AOSContextManager::STATE_LAST, NULL);

  for (int i=0; i<freeStoreInitialSize; ++i)
  {
    m_FreeStore.pushBack(new AOSContext(NULL, m_Services));
  }

  adminRegisterObject(m_Services.useAdminRegistry());
}