private StopInstruction Stop(FiberStatus finalStatus) { // Interlocked isn't necessary because we don't need // the initial value (stops are final). They are also // only called by the scheduler thread during Execute(). status = (int)finalStatus; FinishCompletion(); return(FiberInstruction.Stop); }
/// <summary> /// Invokes the Fiber Action. /// </summary> /// <param name="fiber">the fiber computation.</param> private void InvokeAction(IComputation fiber) { object result = fiber.Execute(); FiberStatus fiberStatus = (FiberStatus)result; if (fiberStatus == FiberStatus.Done) { scheduler.Remove(fiber); } }
/// <summary> /// Executes the given computation. /// </summary> /// <returns></returns> object IComputation.Execute() { try { if (fiberContext.MoveNext() == true && status != FiberStatus.Wait) { status = fiberContext.Current; return(status); } else if (status == FiberStatus.Wait) { status = FiberStatus.Switch; return(status); } else { status = FiberStatus.Done; Cookie.Completed = true; //Internal computation doesn't need to set the event. if (!isInternalComputation && wait != null) { wait.Set(); } } return(status); } catch (Exception ex) { Cookie.IsException = true; Cookie.Exception = ex; if (wait != null) { wait.Set(); } return(FiberStatus.Done); } }
private StopInstruction Stop(FiberStatus finalStatus) { // Interlocked isn't necessary because we don't need // the initial value (stops are final). They are also // only called by the scheduler thread during Execute(). status = (int)finalStatus; FinishCompletion (); return FiberInstruction.Stop; }