public UserCmdParallelExecuteManagerSystem(IGameModule gameModule, IUserCmdExecuteSystemHandler handler, IGameStateProcessorFactory gameStateProcessorFactory, int threadCount) { _systems = new List <IUserCmdExecuteSystem>(); _taskInfos = new List <TaskInfo>(); _systems.Add(new UserCmdPreExecuteSystem(gameStateProcessorFactory)); _systems.AddRange(gameModule.UserCmdExecuteSystems); _systems.Add(new UserCmdPostExecuteSystem()); _handler = handler; int count = _systems.Count; _systemsPool = new List <IUserCmdExecuteSystem> [threadCount]; InitTask(threadCount, count); _mainThread = new WorkThread("Main", _systems); WorkThread[] slaveThreads = new WorkThread[threadCount]; for (var i = 0; i < threadCount; i++) { slaveThreads[i] = new WorkThread("Slave", _systemsPool[i]); } _taskDisparcher = new TaskDispatcher(threadCount, _mainThread, slaveThreads, _taskInfos); _mainThread.Name = "MainThread"; _mainThread.SetTaskDisparcher(_taskDisparcher); for (var i = 0; i < threadCount; i++) { slaveThreads[i].SetTaskDisparcher(_taskDisparcher); slaveThreads[i].Name = string.Format("SlaveThreads:{0}", i); } _taskDisparcher.Start(); }
public static void SortStash() { if (!BotMain.IsRunning) { TaskDispatcher.Start(ret => SortTask(InventorySlot.SharedStash), ret => !IsSorting); return; } try { GoldInactivity.Instance.ResetCheckGold(); XpInactivity.Instance.ResetCheckXp(); if (!_hookInserted) { _sortBehavior = CreateSortBehavior(inventorySlot: InventorySlot.SharedStash); TreeHooks.Instance.InsertHook(HookName, 0, _sortBehavior); _hookInserted = true; BotMain.OnStop += bot => RemoveBehavior(); } } catch (Exception ex) { Logger.LogError("Error running Sort stash: " + ex); RemoveBehavior(); } }
public static void RunCleanStash() { if (!BotMain.IsRunning) { TaskDispatcher.Start(ret => CleanTask(), ret => !IsCleaning); return; } try { GoldInactivity.Instance.ResetCheckGold(); XpInactivity.Instance.ResetCheckXp(); if (!_hookInserted) { _cleanBehavior = CreateCleanBehavior(); TreeHooks.Instance.InsertHook(HookName, 0, _cleanBehavior); _hookInserted = true; BotMain.OnStop += bot => RemoveBehavior("Bot stopped"); } } catch (Exception ex) { Logger.LogError("Error running clean stash: " + ex); RemoveBehavior("Exception"); } }
public override void Start(string [] args) { TaskDispatcher = StaticServiceProvider.Provider.GetService <ITaskDispatcher> ( ); TaskDispatcher.Start( ); Type pageBlobProviderType = AppDomain.CurrentDomain.GetAssemblies( ). SelectMany( assembly => assembly.GetTypes( )). Where( type => typeof(IPageBlobProvider). IsAssignableFrom(type)). FirstOrDefault( type => type.Name == Setting.PageBlob); if (pageBlobProviderType is null) { Logger.LogCritical("Can not found Type named {0}.", Setting.PageBlob); Exit(ProgramExitCode.InvalidSetting); return; } else { Logger.LogInformation( "Using {0}.", pageBlobProviderType.AssemblyQualifiedName); StaticServiceProvider.ServiceCollection.AddSingleton <IPageBlobProvider> ( ( IPageBlobProvider )Activator. CreateInstance( pageBlobProviderType)); StaticServiceProvider.Update( ); } if (string.IsNullOrWhiteSpace(Setting.SqlConnectionString)) { Logger.LogCritical( "Current setting file lacks required settings, check setting file and start program again."); Exit(ProgramExitCode.InvalidSetting); return; } if (IsRunning) { Service = new CloudFileSystemService( ); Environment.ExitCode = Service.Run( ); } Exit( ); }
public TaskWorker Start() { if (isStarted) throw new Exception("already running"); dispatcher = new TaskDispatcher(queue); dispatcher.Start(); isStarted = true; return this; }
public GraphicsDevice(IntPtr Handle, int Width, int Height) { Context_ = new GraphicsContext(this, new Box(0, 0, Width, Height)); Swapchain_ = new Swapchain(Handle, Width, Height); TaskDispatcher_ = new TaskDispatcher(this, Context_.CoreNum); TaskDispatcher_.Enable = true; TaskDispatcher_.Start(); ProfilerHelper_ = new Profiler(); ProfilerHelper_.Enable = true; Pipeline_ = new Pipeline(this); }