public Messenger(ILogger logger, IGoGRepository goGRepository) { logger.LogGameInfo(Guid.Empty, "Entering Fuego (service) constructor."); _logger = logger; _goGRepository = goGRepository; // Initialize the singleton fuego engine using the repository of choice. FuegoEngine.Init(logger, _goGRepository); // Spins up the fuego.exe instances. }
public FuegoInstance(IGoGRepository goGRepository, long memoryPerInstance, ILogger logger) { _goGRepository = goGRepository; _memoryPerInstance = memoryPerInstance; _logger = logger; CurrentOperation = GoOperation.Idle; logger.LogGameInfo(Guid.Empty, "Starting a new FuegoInstance."); EnsureRunning(); }
public static void Init(ILogger logger, IGoGRepository goGRepository) { // Lock is static. This prevents multiple requests from trying to both initialize. Instead, // the first request will do the initialization, and the subsequents requests will get stuck // here until the first request is finished initializing. We can't just return immediately on the // subsequent requests because they would try to use the not-yet-fully-initialized "Instance" and // cause an exception or invalid state. lock (Lock) { if (Instance != null) { return; } Instance = new FuegoEngine(); Instance.Setup(logger, goGRepository); } }
private void Setup(ILogger logger, IGoGRepository goGRepository) { _logger = logger; _goGRepository = goGRepository; var cleanupInMinutess = Convert.ToInt32(ConfigurationManager.AppSettings["CleanupIntervalInMinutes"]); _cleanupInterval = TimeSpan.FromMinutes(cleanupInMinutess); _instances = new HashSet <FuegoInstance>(); _maxInstances = Convert.ToByte(ConfigurationManager.AppSettings["FuegoInstances"]); var gb = Convert.ToDecimal(ConfigurationManager.AppSettings["GBPerFuegoInstance"]); _memoryPerInstance = (long)Decimal.Round((decimal)1024 * 1024 * 1024 * gb); Cleanup(); // Spin up copies of fuego.exe up to instance limit. for (int i = 0; i < Instance._maxInstances; i++) { var instance = new FuegoInstance(_goGRepository, _memoryPerInstance, _logger); _instances.Add(instance); } }