/// <summary> /// Process job result. /// </summary> /// <param name="res">Result.</param> private ComputeJobResultPolicy JobResult0(IComputeJobResult <object> res) { try { IList <IComputeJobResult <T> > ress0; // 1. Prepare old results. if (_resCache) { if (_resJobs == null) { _resJobs = new HashSet <object>(); _ress = new List <IComputeJobResult <T> >(); } ress0 = _ress; } else { ress0 = EmptyRes; } // 2. Invoke user code. var policy = _task.Result(new ComputeJobResultGenericWrapper <T>(res), ress0); // 3. Add result to the list only in case of success. if (_resCache) { var job = res.Job().Unwrap(); if (!_resJobs.Add(job)) { // Duplicate result => find and replace it with the new one. var oldRes = _ress.Single(item => item.Job() == job); _ress.Remove(oldRes); } _ress.Add(new ComputeJobResultGenericWrapper <T>(res)); } return(policy); } catch (Exception e) { Finish(default(TR), e); if (!(e is IgniteException)) { throw new IgniteException("Failed to process job result: " + e.Message, e); } throw; } }
/** <inheritdoc /> */ public IComputeJob <T> Job() { return(_wrappedRes.Job().Unwrap <object, T>()); }