public void Start() { processor = new AsyncProcessor(); processor.Process(Coroutine1()); processor.Process(GetExample1()); processor.Process(GetExample2()); }
IEnumerator Loading(AsyncOperation progress, LoadingScreenBehaviour ls) { ls.Begin(); LoadingState state = ls.state; while (!progress.isDone) { state.Callback("LoadingScene", progress.progress); yield return(null); } List <Action> doneListeners = new List <Action>(); var initializer = GetInitializer(); if (initializer != null) { state.Callback("InitializingScene", 0); yield return(null); AsyncProcessor processor = new AsyncProcessor(this); yield return(initializer.Initialize(processor, doneListeners.Add, state)); yield return(new WaitUntil(processor.allDone)); } ls.End(); Done(); foreach (var dl in doneListeners) { dl.Invoke(); } }
public void TestReenteringJobMixedWithOrdinaryJobs() { _jobCount = 0; AsyncProcessor processor = new AsyncProcessor(false); using ( processor ) { const int total = 10; processor.QueueJob(JobPriority.AboveNormal, new SleepJob(0)); processor.QueueJob(JobPriority.AboveNormal, new SleepJob(0)); processor.QueueJob(JobPriority.AboveNormal, new SleepJob(0)); processor.QueueJob(JobPriority.AboveNormal, new SleepJob(0)); processor.QueueJob(new GroupJob(total, total)); processor.QueueJob(new SleepJob(300)); processor.QueueJob(new SleepJob(0)); processor.QueueJob(new SleepJob(0)); processor.QueueJob(JobPriority.Immediate, new SleepJob(0)); processor.StartThread(); Thread.Sleep(200); if (_jobCount != total + 7) { throw new Exception("TestReenteringJobMixedWithOrdinaryJobs() failed (first check). _jobCount = " + _jobCount); } Thread.Sleep(150); if (_jobCount != total + 11) { throw new Exception("TestReenteringJobMixedWithOrdinaryJobs() failed (second check). _jobCount = " + _jobCount); } } }
public LevelVibrationManager(SignalBus signalBus, AsyncProcessor asyncProcessor) { _signalBus = signalBus; _asyncProcessor = asyncProcessor; signalBus.Subscribe <PlayerChangedColorSignal>(s => this.OnPlayerChangedColor(s)); signalBus.Subscribe <LevelEndSignal>(s => this.OnLevelEnd(s)); }
public void TestMultipleAsyncProcessors() { const int count = 300000; AsyncProcessor lockProcessor1 = new AsyncProcessor(false); AsyncProcessor lockProcessor2 = new AsyncProcessor(false); AsyncProcessor lockProcessor3 = new AsyncProcessor(false); AsyncProcessor lockProcessor4 = new AsyncProcessor(false); ArrayList lockJobs = new ArrayList(count); for (int i = 0; i < count; ++i) { lockJobs.Add(new LockJob()); } for (int i = 0; i < count; ++i) { lockProcessor1.QueueJob((AbstractJob)lockJobs[i]); lockProcessor2.QueueJob((AbstractJob)lockJobs[i]); lockProcessor3.QueueJob((AbstractJob)lockJobs[i]); lockProcessor4.QueueJob((AbstractJob)lockJobs[i]); } lockProcessor1.QueueEndOfWork(); lockProcessor2.QueueEndOfWork(); lockProcessor3.QueueEndOfWork(); lockProcessor4.QueueEndOfWork(); lockProcessor1.StartThread(); lockProcessor2.StartThread(); lockProcessor3.StartThread(); lockProcessor4.StartThread(); lockProcessor1.WaitUntilFinished(); lockProcessor2.WaitUntilFinished(); lockProcessor3.WaitUntilFinished(); lockProcessor4.WaitUntilFinished(); }
[SetUp] public void SetUp() { try { string[] files = System.IO.Directory.GetFiles(".", "_*"); foreach (string fileName in files) { System.IO.File.Delete(fileName); } } catch (Exception exc) { Assert.Fail(exc.Message); } OMEnv.DataDir = ".\\Data"; InitStorage(); for (int i = 0; i < _processors.Length; ++i) { _processors[i] = new AsyncProcessor(new AsyncExceptionHandler(ExceptionHandler), false); } MockPluginEnvironment env = new MockPluginEnvironment(_storage); env.SetCoreProps(new MockCoreProps()); indexer = new FullTextIndexer(); indexer.Initialize(); Core.ResourceStore.ResourceTypes.Register("TestType", "TestType", "Name", ResourceTypeFlags.Normal); }
private void menuItem3_Popup(object sender, System.EventArgs e) { ThreadPriority priority = ThreadPriority.Normal; foreach (ListViewItem item in _listView.SelectedItems) { AsyncProcessor proc = item.Tag as AsyncProcessor; if (proc != null) { priority = proc.ThreadPriority; } } menuItem4.Checked = menuItem5.Checked = menuItem6.Checked = menuItem7.Checked = menuItem8.Checked = false; switch (priority) { case ThreadPriority.Lowest: menuItem4.Checked = true; break; case ThreadPriority.BelowNormal: menuItem5.Checked = true; break; case ThreadPriority.Normal: menuItem6.Checked = true; break; case ThreadPriority.AboveNormal: menuItem7.Checked = true; break; case ThreadPriority.Highest: menuItem8.Checked = true; break; } }
public void Start() { processor = new AsyncProcessor(); processor.Process(Coroutine1()); processor.Process(GetExample1()); processor.Process(GetExample2()); }
public Task <AsyncProcessor> AsyncProcessorAsync(AsyncProcessor input, CancellationToken cancellationToken = default) { return(Task.FromResult(new AsyncProcessor() { Foo = input.Foo })); }
private void RefreshItems(bool displayThreadTimes) { AsyncProcessor[] procs = AsyncProcessor.GetAllPooledProcessors(); _listView.BeginUpdate(); try { _listView.Items.Clear(); foreach (AsyncProcessor proc in procs) { ListViewItem item = new ListViewItem(); item.Tag = proc; item.Text = proc.ThreadName; item.SubItems.Add(proc.ThreadPriority.ToString()); if (displayThreadTimes) { item.SubItems.Add(proc.GetKernelTime().ToString()); item.SubItems.Add(proc.GetUserTime().ToString()); } _listView.Items.Add(item); } } finally { _listView.EndUpdate(); } }
public void TestAsyncProcessorEvents() { _jobCount = 0; AsyncProcessor proc = new AsyncProcessor(false); using ( proc ) { proc.ThreadStarted += new EventHandler(proc_ThreadStarted); proc.ThreadStarted += new EventHandler(proc_ThreadStarted1); proc.ThreadStarted += new EventHandler(proc_ThreadStarted2); proc.ThreadFinished += new EventHandler(proc_ThreadStarted); proc.ThreadFinished += new EventHandler(proc_ThreadStarted1); proc.FillingEmptyQueue += new EventHandler(proc_FillingEmptyQueue); proc.QueueGotEmpty += new EventHandler(proc_QueueGotEmpty); proc.QueueGotEmpty += new EventHandler(proc_QueueGotEmpty1); proc.JobStarting += new EventHandler(proc_JobStarting); proc.JobFinished += new EventHandler(proc_JobFinished); proc.JobQueued += new JetBrains.Omea.AsyncProcessing.AsyncProcessor.JobDelegate(proc_JobQueued); proc.QueueJob(new SleepJob(0)); proc.QueueJob(new SleepJob(0)); proc.QueueJob(new SleepJob(0)); proc.QueueJob(new SleepJob(0)); proc.QueueEndOfWork(); proc.EmployCurrentThread(); } if (_jobCount != 0) { throw new Exception("TestAsyncProcessorEvents() failed. _jobCount = " + _jobCount); } }
public void TestQueueGotEmpty() { _jobCount = 0; AsyncProcessor proc = new AsyncProcessor(); using ( proc ) { proc.QueueGotEmpty += new EventHandler(proc_QueueGotEmpty); proc.ThreadFinished += new EventHandler(proc_ThreadStarted1); proc.QueueJob(new SleepJob(0)); proc.QueueJob(new EnumeratorJob(3, 200)); Thread.Sleep(300); if (_jobCount != 3) { throw new Exception("TestQueueGotEmpty() failed (first check). _jobCount = " + _jobCount); } Thread.Sleep(200); if (_jobCount != 4) { throw new Exception("TestQueueGotEmpty() failed (second check). _jobCount = " + _jobCount); } Thread.Sleep(300); if (_jobCount != 8) { throw new Exception("TestQueueGotEmpty() failed (third check). _jobCount = " + _jobCount); } } if (_jobCount != 4) { throw new Exception("TestQueueGotEmpty() failed (final check). _jobCount = " + _jobCount); } }
public PmViewErrorHandler( PmView view, AsyncProcessor asyncProcessor) { _view = view; _asyncProcessor = asyncProcessor; }
/// <summary> /// Libera a instancia. /// </summary> /// <param name="disposing"></param> private void Dispose(bool disposing) { lock (this) { if (this.SerializationContext != null) { CompactFormatterServices.UnregisterAllCustomCompactTypes(this.SerializationContext); } if (this.ExpiryMgr != null) { this.ExpiryMgr.Dispose(); this.ExpiryMgr = null; } if (this.CacheImpl != null) { this.CacheImpl.Dispose(); this.CacheImpl = null; } if (this.TimeSched != null) { this.TimeSched.Dispose(); this.TimeSched = null; } if (this.AsyncProc != null) { this.AsyncProc.Stop(); this.AsyncProc = null; } if (disposing) { GC.SuppressFinalize(this); } } }
public VictoryState(AsyncProcessor asyncProcessor, GameManager gameManager, Settings settings) { _asyncProcessor = asyncProcessor; _gameManager = gameManager; _settings = settings; }
public PersonalLifeHandler(IPlayerInfoHolder playerInfoHolder, IGameInfoHolder gameInfoHolder, AsyncProcessor asyncProcessor) { _playerInfoHolder = playerInfoHolder; _gameInfoHolder = gameInfoHolder; _asyncProcessor = asyncProcessor; _increasePrivateLife = _asyncProcessor.StartCoroutine(IncreasePrivateLife()); }
IEnumerator ISceneInitializer.Initialize(AsyncProcessor asyncProcessor, AddListener addDoneListener, LoadingState state) { Time.timeScale = 0; Time.fixedDeltaTime = 0; addDoneListener(LoadingDone); yield return(Initialize(asyncProcessor, state)); }
public GameManager(GameSettings gameSettings, AsyncProcessor asyncProcessor, LevelManager levelManager, PlayerPool playerPool, SignalBus signalBus) { _asyncProcessor = asyncProcessor; _gameSettings = gameSettings; _levelManager = levelManager; _playerPool = playerPool; _signalBus = signalBus; }
public TaskMessagesHandler(AsyncProcessor asyncProcessor) { _asyncProcessor = asyncProcessor; _nextMessageWaitors = new Coroutine[3]; StartWaitForNextMessage(0); StartWaitForNextMessage(1); StartWaitForNextMessage(2); }
private void Awake() { processor = new AsyncProcessor(); stateMachine = new StateMachine(processor, fadingEffect); // This line is intentionally added for creating all static state. It will be removed if using DI framework. StateRepository stateRepository = new StateRepository(new NullState(), new TestOneState(stateMachine), new TestTwoState(stateMachine)); }
public PmViewAsyncHandler( PmView view, AsyncProcessor asyncProcessor, PmSettings pmSettings) { _pmSettings = pmSettings; _asyncProcessor = asyncProcessor; _view = view; }
public TextQueriesOptimizationManager(AsyncProcessor processor, FullTextIndexer indexer) { _textProcessor = processor; _textIndexer = indexer; _queryResults = new Dictionary <string, IntArrayList>(); _activeQueries = new List <string>(); InitializeConditionsList(); InitializeListeners(); }
private void menuItem2_Click(object sender, System.EventArgs e) { foreach (ListViewItem item in _listView.SelectedItems) { AsyncProcessor proc = item.Tag as AsyncProcessor; if (proc != null) { proc.Thread.Abort(); } } }
public void Initialize(Color color, float radius, AsyncProcessor asyncProcessor) { if (asyncProcessor != null) { asyncProcessor.Process(() => AsyncInitialize(color, radius)); } else { Initialize(color, radius); } }
public PmInputHandler( PmView view, PmModel model, PmPackageHandler packageHandler, AsyncProcessor asyncProcessor) { _asyncProcessor = asyncProcessor; _packageHandler = packageHandler; _model = model; _view = view; }
private int AsyncUpdateEntries(UpdateState state, List <UpdateEntry>[] moveList) { Xen.Threading.ThreadPool pool = state.Application.ThreadPool; if (entriesHighIndex < 2) { return(UpdateEntries(state, moveList)); } if (asyncProcessors == null) { asyncProcessors = new AsyncProcessor[pool.ThreadCount]; for (int i = 0; i < asyncProcessors.Length; i++) { asyncProcessors[i] = new AsyncProcessor(this); } } asyncIndex = -1; for (int i = 0; i < asyncProcessors.Length; i++) { asyncProcessors[i].callback = pool.QueueTask(asyncProcessors[i], state); } AsyncUpdateEntriesThread(state, moveList, null); for (int i = 0; i < asyncProcessors.Length; i++) { asyncProcessors[i].callback.WaitForCompletion(); if (asyncProcessors[i].moveList.Count > 0) { foreach (KeyValuePair <UpdateFrequency, UpdateEntry> entry in asyncProcessors[i].moveList) { moveList[(int)entry.Key].Add(entry.Value); } } asyncProcessors[i].moveList.Clear(); } int count = 0; for (int i = 0; i < entriesHighIndex; i++) { if (entries[i] != null) { entries[i].index = count; } if ((entries[count] = entries[i]) != null) { count++; } } return(count); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or /// resetting unmanaged resources. /// </summary> /// <param name="disposing"></param> private void Dispose(bool disposing) { lock (this) { if (SerializationContext != null) { CompactFormatterServices.UnregisterAllCustomCompactTypes(SerializationContext); } if (PerfStatsColl != null) { PerfStatsColl.Dispose(); PerfStatsColl = null; } if (ExpiryMgr != null) { ExpiryMgr.Dispose(); ExpiryMgr = null; } if (MessageManager != null) { MessageManager.StopMessageProcessing(); MessageManager = null; } if (CacheImpl != null) { CacheImpl.Dispose(); CacheImpl = null; } if (TimeSched != null) { TimeSched.Dispose(); TimeSched = null; } if (AsyncProc != null) { AsyncProc.Stop(); AsyncProc = null; } if (HealthCollectorTimeSched != null) { HealthCollectorTimeSched.Dispose(); HealthCollectorTimeSched = null; } if (disposing) { GC.SuppressFinalize(this); } } }
private void sleepOn10Sec(object sender, System.EventArgs e) { foreach (ListViewItem item in _listView.SelectedItems) { AsyncProcessor proc = item.Tag as AsyncProcessor; if (proc != null) { proc.QueueJob("10 seconds sleeping", new MethodInvoker(Sleep10Seconds)); } } }
private void menuItem1_Click(object sender, System.EventArgs e) { foreach (ListViewItem item in _listView.SelectedItems) { AsyncProcessor proc = item.Tag as AsyncProcessor; if (proc != null) { proc.QueueJob("Throw Exception", new MethodInvoker(ExceptionJob)); } } }
public void Initialize(SunBehaviour sun, Vector3 axis, float radius, AsyncProcessor asyncProcessor) { if (asyncProcessor != null) { asyncProcessor.Process(() => AsyncInitialize(sun, axis, radius)); } else { Initialize(sun, axis, radius); } }
private void SetThreadPriority(ThreadPriority priority) { foreach (ListViewItem item in _listView.SelectedItems) { AsyncProcessor proc = item.Tag as AsyncProcessor; if (proc != null) { proc.ThreadPriority = priority; } } }
public PmWindowInitializer( PmProjectHandler projectHandler, PmPackageHandler packageHandler, PmReleasesHandler releasesHandler, AsyncProcessor asyncProcessor) { _releasesHandler = releasesHandler; _packageHandler = packageHandler; _projectHandler = projectHandler; _asyncProcessor = asyncProcessor; }
public PmCreateNewProjectPopupHandler( PmView view, AsyncProcessor asyncProcessor, PrjCommandHandler commandHandler, PmWindowInitializer windowInitializer) { _windowInitializer = windowInitializer; _commandHandler = commandHandler; _asyncProcessor = asyncProcessor; _view = view; }
public LevelEndAnimationManager( SignalBus signalBus, AsyncProcessor asyncProcessor, LevelUIController uiController, PlayerController playerController, InputPlayerController inputPlayerController ) { _signalBus = signalBus; _asyncProcessor = asyncProcessor; _playerController = playerController; _inputPlayerController = inputPlayerController; _uiController = uiController; }
public PmPackageViewHandler( PmView view, AsyncProcessor asyncProcessor, PmPackageHandler packageHandler, PrjCommandHandler prjCommandHandler, PmSettings pmSettings) { _pmSettings = pmSettings; _prjCommandHandler = prjCommandHandler; _packageHandler = packageHandler; _asyncProcessor = asyncProcessor; _view = view; }
public void SetUp() { InitStorage(); RegisterResourcesAndProperties(); for (int i = 0; i < _processors.Length; ++i) { _processors[i] = new AsyncProcessor(new AsyncExceptionHandler(ExceptionHandler), false); } _wereExceptions = false; _traceListener = new ConsoleOutListener(); Trace.Listeners.Add(_traceListener); }
public PmDragDropHandler( PmModel model, PmView view, AsyncProcessor asyncProcessor, PmPackageHandler packageHandler, PrjCommandHandler prjCommandHandler) { _prjCommandHandler = prjCommandHandler; _packageHandler = packageHandler; _asyncProcessor = asyncProcessor; _view = view; _model = model; }
public PmVsSolutionViewHandler( PmModel model, PmView view, AsyncProcessor asyncProcessor, PrjCommandHandler prjCommandHandler, PmProjectHandler projectHandler) { _projectHandler = projectHandler; _prjCommandHandler = prjCommandHandler; _asyncProcessor = asyncProcessor; _model = model; _view = view; }
[SetUp] public void SetUp() { _core = new TestCore(); _resourceAP = new AsyncProcessor(true); _core.SetResourceAP(_resourceAP); _storage = _core.ResourceStore; _storage = _storage; MyPalStorage.Storage.OwnerThread = _resourceAP.Thread; _manager = new ProtocolHandlerManager(); _core.SetProtocolHandlerManager(_manager); _plugin = new MockPlugin(); _resourceAP.RunJob(new MethodInvoker(RegisterResources)); }
public PmCreateNewProjectPopupHandler( PmView view, AsyncProcessor asyncProcessor, PrjCommandHandler commandHandler, PmWindowInitializer windowInitializer, PmSettings pmSettings) { _settings = pmSettings.CreateNewPopup; _pmSettings = pmSettings; _windowInitializer = windowInitializer; _commandHandler = commandHandler; _asyncProcessor = asyncProcessor; _view = view; }
public PmProjectViewHandler( PmModel model, PmView view, PmProjectHandler projectHandler, AsyncProcessor asyncProcessor, PrjCommandHandler prjCommandHandler, PmViewErrorHandler errorHandler) { _errorHandler = errorHandler; _prjCommandHandler = prjCommandHandler; _asyncProcessor = asyncProcessor; _model = model; _view = view; _projectHandler = projectHandler; }
public PmReleasesViewHandler( PmModel model, PmView view, AsyncProcessor asyncProcessor, PmReleasesHandler releasesHandler, PmPackageHandler packageHandler, PrjCommandHandler prjCommandHandler, PmSettings pmSettings) { _pmSettings = pmSettings; _prjCommandHandler = prjCommandHandler; _packageHandler = packageHandler; _releasesHandler = releasesHandler; _asyncProcessor = asyncProcessor; _view = view; _model = model; }
public void Setup() { _asyncHandler = new AsyncProcessor(); }
void SetupDependencies() { // We could use a DI framework like zenject here but it's overkill // and also we'd like to keep the dependencies for Projeny low // So just do poor man's DI instead _asyncProcessor = new AsyncProcessor(); _settings = Resources.Load<PmSettings>("Projeny/PmSettings"); _view = new PmView(_viewModel, _settings); _prjCommandHandler = new PrjCommandHandler(_view); _packageHandler = new PmPackageHandler(_model, _prjCommandHandler, _view); _releasesHandler = new PmReleasesHandler(_model, _prjCommandHandler); _inputHandler = new PmInputHandler(_view, _model, _packageHandler, _asyncProcessor); _viewErrorHandler = new PmViewErrorHandler(_view, _asyncProcessor); _viewAsyncHandler = new PmViewAsyncHandler(_view, _asyncProcessor, _settings); _viewModelSyncer = new PmModelViewSyncer(_model, _view, _settings); _projectHandler = new PmProjectHandler(_model, _view); _dragDropHandler = new PmDragDropHandler(_model, _view, _asyncProcessor, _packageHandler, _prjCommandHandler); _packageViewHandler = new PmPackageViewHandler(_view, _asyncProcessor, _packageHandler, _prjCommandHandler, _settings); _windowInitializer = new PmWindowInitializer(_projectHandler, _packageHandler, _releasesHandler, _asyncProcessor); _createNewProjectHandler = new PmCreateNewProjectPopupHandler(_view, _asyncProcessor, _prjCommandHandler, _windowInitializer); _projectViewHandler = new PmProjectViewHandler( _model, _view, _projectHandler, _asyncProcessor, _prjCommandHandler, _viewErrorHandler); _solutionViewHandler = new PmVsSolutionViewHandler( _model, _view, _asyncProcessor, _prjCommandHandler, _viewErrorHandler, _projectHandler); _releasesViewHandler = new PmReleasesViewHandler( _model, _view, _asyncProcessor, _releasesHandler, _packageHandler, _prjCommandHandler, _settings); }