public void Setup() { _task1 = new ServiceTask(); _task2 = new ServiceTask(); _serialTasks1 = new SerialTaskCollection(); }
private void Traverse(PlayerEntityView entityView, List <HexCell> path) { var coordComp = entityView.coordinatesComponent; var moveComp = entityView.movementComponent; //if (moveComp.isWalking) return; var serialTasks = new SerialTaskCollection(); for (var i = 1; i < path.Count; i++) { HexCell from = path[i - 1]; HexCell to = path[i]; HexDirection dir = from.GetDirection(to); if (coordComp.direction != dir) { coordComp.direction = dir; serialTasks.Add(Turn(entityView, dir)); } serialTasks.Add(Walk(entityView, to)); } serialTasks.onComplete += () => { moveComp.isWalking = false; }; serialTasks.Run(); }
// Use this for initialization void Start() { var someData = new SomeData(); var pt = new ParallelTaskCollection <SomeData>(someData); var st = new SerialTaskCollection <SomeData>(someData); st.Add(Print("s1")); st.Add(Print("s2")); st.Add(pt); st.Add(Print("s3")); st.Add(Print("s4")); pt.Add(Print("1")); pt.Add(Print("2")); pt.Add(DoSomethingAsynchonously()); pt.Add(new LoadSomething(new WWW("www.google.com"))); //obviously the token could be passed by constructor, but in some complicated situations, this is not possible (usually while exploiting continuation) pt.Add(new LoadSomething(new WWW("http://download.thinkbroadband.com/5MB.zip"))); pt.Add(new LoadSomething(new WWW("www.ebay.com"))); pt.Add(Print("3")); pt.Add(Print("4")); pt.Add(Print("5")); pt.Add(Print("6")); pt.Add(Print("7")); pt.Add(Print(someData.justForTest.ToString())); TaskRunner.Instance.Run(st); }
// Use this for initialization void Start() { Application.targetFrameRate = 60; Debug.Log("Set frame rate to 60fps"); ParallelTaskCollection pt = new ParallelTaskCollection(); SerialTaskCollection st = new SerialTaskCollection(); st.Add(Print("s1")); st.Add(DoSomethingAsynchonously()); st.Add(Print("s3")); pt.Add(Print("1")); pt.Add(Print("2")); pt.Add(Print("3")); pt.Add(Print("4")); pt.Add(Print("5")); pt.Add(st); pt.Add(Print("6")); pt.Add(WWWTest()); pt.Add(Print("7")); pt.Add(Print("8")); pt.onComplete += () => { Application.targetFrameRate = -1; Debug.Log("Unlock framerate"); }; pt.Run(); }
IEnumerator UpdateIT() { var waitForSecondsEnumerator = new WaitForSecondsEnumerator(0.1f); var syncRunner = new SyncRunner <Allocation0Enumerator>(); var syncRunner2 = new SyncRunner <WaitForSecondsEnumerator>(); var task = TaskRunner.Instance.AllocateNewTaskRoutine(syncRunner2).SetEnumeratorRef(ref waitForSecondsEnumerator); var task2 = TaskRunner.Instance.AllocateNewTaskRoutine(syncRunner); var serialtask = new SerialTaskCollection <Allocation0Enumerator>(); int counter = 0; while (true) { yield return(task.Start()); //yield return new Allocation0Enumerator(counter++); //nay this allocates yield return(task2.SetEnumerator(new Allocation0Enumerator(counter++)).Start()); //yay, this doesn't allocate! yield return(serialtask.Add(new Allocation0Enumerator(counter))); //yay, this doesn't allocate! serialtask.Clear(); yield return(null); } }
// Use this for initialization void Start() { var pt = new ParallelTaskCollection(); var st = new SerialTaskCollection(); st.Add(Print("s1")); st.Add(Print("s2")); st.Add(pt); st.Add(Print("s3")); st.Add(Print("s4")); pt.Add(Print("1")); pt.Add(Print("2")); //only the task runner can actually handle parallel tasks //that return Unity operations (when unity compatible //schedulers are used) pt.Add(UnityAsyncOperationsMustNotBreakTheParallelism()); pt.Add(UnityYieldInstructionsMustNotBreakTheParallelism()); pt.Add(new LoadSomething(new UnityWebRequest("www.google.com")).GetEnumerator()); //obviously the token could be passed by constructor, but in some complicated situations, this is not possible (usually while exploiting continuation) pt.Add(new LoadSomething(new UnityWebRequest("http://download.thinkbroadband.com/5MB.zip")).GetEnumerator()); pt.Add(new LoadSomething(new UnityWebRequest("www.ebay.com")).GetEnumerator()); pt.Add(Print("3")); pt.Add(Print("4")); pt.Add(Print("5")); pt.Add(Print("6")); pt.Add(Print("7")); st.Start(); }
internal PausableTask() { _coroutineWrapper = new SerialTaskCollection(1); _continuationWrapper = new ContinuationWrapper(); Reset(); }
internal PausableTask() { _enumeratorWrap = new EnumeratorWrapper(); _coroutineWrapper = new SerialTaskCollection(1); Reset(); }
public void Setup() { _serialTasks1 = new SerialTaskCollection(); _serialTasks2 = new SerialTaskCollection(); _parallelTasks1 = new ParallelTaskCollection(); _parallelTasks2 = new ParallelTaskCollection(); _iterable1 = new Enumerator(10000); _iterable2 = new Enumerator(5000); _reusableTaskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine(new SyncRunner()); }
public SingleTask(IEnumerator enumerator) { if (enumerator is SingleTask || enumerator is PausableTask || enumerator is AsyncTask) throw new ArgumentException("Internal task used outside the framework scope"); _task = new SerialTaskCollection(); _task.Add(enumerator); _enumerator = _task.GetEnumerator(); _onComplete = null; }
void Start() { SerialTaskCollection st = new SerialTaskCollection(); st.Add(Print(1)); st.Add(Print(2)); st.Add(DoSomethingAsynchonously(1)); st.Add(Print(3)); st.Add(WaitForSecondsTest()); st.Add(Print(4)); st.Add(WWWTest()); st.Add(Print(5)); st.Add(Print(6)); TaskRunner.Instance.Run(st); }
// Use this for initialization void Start() { ParallelTaskCollection pt = new ParallelTaskCollection(); SerialTaskCollection st = new SerialTaskCollection(); st.Add(Print("s1")); st.Add(Print("s2")); st.Add(Print("s3")); st.Add(Print("s4")); pt.Add(Print("p1")).Add(Print("p2")); pt.Add(new LoadSomething(new WWWEnumerator(new WWW("www.google.com")))); //obviously the token could be passed by constructor, but in some complicated situations, this is not possible (usually while exploiting continuation) pt.Add(new LoadSomething(new WWWEnumerator(new WWW("http://download.thinkbroadband.com/5MB.zip")))); pt.Add(new LoadSomething(new WWWEnumerator(new WWW("www.ebay.com")))); pt.Add(Print("p3")).Add(Print("p4")).Add(st).Add(Print("p5")).Add(Print("p6")).Add(Print("p7")); TaskRunner.Instance.RunOnSchedule(MTRunner, pt); //running on another thread! }
public void Setup() { vo = new ValueObject(); serialTasks1 = new SerialTaskCollection <ValueObject>(vo); parallelTasks1 = new ParallelTaskCollection <ValueObject>(vo); serialTasks2 = new SerialTaskCollection <ValueObject>(vo); parallelTasks2 = new ParallelTaskCollection <ValueObject>(vo); task1 = new Task(); task2 = new Task(); taskChain1 = new TaskChain(); taskChain2 = new TaskChain(); iterable1 = new Enumerable(10000); iterable2 = new Enumerable(10000); iterableWithException = new Enumerable(-5); _taskRunner = TaskRunner.Instance; _reusableTaskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine().SetScheduler(StandardSchedulers.syncScheduler); //the taskroutine will stall the thread because it runs on the SyncScheduler }
public void Setup() { _vo = new ValueObject(); _serialTasks1 = new SerialTaskCollection <TestEnumerator>(); _parallelTasks1 = new ParallelTaskCollection <IEnumerator>(); _serialTasks2 = new SerialTaskCollection(); _parallelTasks2 = new ParallelTaskCollection(); _task1 = new Task(); _task2 = new Task(); _asyncTaskChain1 = new AsyncTask(); _asyncTaskChain2 = new AsyncTask(); _iterable1 = new TestEnumerator(10000); _iterable2 = new TestEnumerator(10000); _iterableWithException = new TestEnumerator(-5); _taskRunner = TaskRunner.Instance; //the taskroutine will stall the thread because it runs on the SyncScheduler _reusableTaskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine(new SyncRunner()); }
public SyncRunner(int timeout = 1000) : base(timeout) { _taskCollection = new SerialTaskCollection <IEnumerator <TaskContract> >(); }
internal SveltoTask() { _coroutineWrapper = new SerialTaskCollection <T>(1); }
public CoroutineEx() { _task = new SerialTaskCollection(1); }
public SerialIEnumerator() { stc = new SerialTaskCollection(); stc.AddFinishAction(finish); }