public virtual IFuture <T> Submit(IRunnableFuture <T> runnableFuture) { if (runnableFuture == null) { throw new ArgumentNullException("runnableFuture"); } return(DoSubmit(runnableFuture)); }
internal QueueingFuture(ExecutorCompletionService <T> enclosingInstance, IRunnableFuture <T> task) : base(task, null) { _enclosingInstance = enclosingInstance; _task = task; var contextCopyingTask = task as IContextCopyingTask; if (contextCopyingTask != null && contextCopyingTask.ContextCarrier != null) { // The task is already copying the context, so we don't do it again. ((IContextCopyingTask)this).ContextCarrier = NoContextCarrier.Instance; } }
private List <IFuture <T> > DoInvokeAll <T>(IEnumerable tasks, int count, Converter <object, IRunnableFuture <T> > converter) { if (tasks == null) { throw new ArgumentNullException("tasks"); } List <IFuture <T> > futures = count > 0 ? new List <IFuture <T> >(count) : new List <IFuture <T> >(); bool done = false; try { foreach (object task in tasks) { IRunnableFuture <T> runnableFuture = converter(task); futures.Add(runnableFuture); Execute(runnableFuture); } foreach (IFuture <T> future in futures) { if (!future.IsDone) { try { future.GetResult(); } catch (CancellationException) { } catch (ExecutionException) { } } } done = true; return(futures); } finally { if (!done) { foreach (IFuture <T> future in futures) { future.Cancel(true); } } } }
internal IFuture <T> DoSubmit(IRunnableFuture <T> runnableFuture) { _executor.Execute(new QueueingFuture(this, runnableFuture)); return(runnableFuture); }
private IFuture <T> Submit <T>(IRunnableFuture <T> runnableFuture) { Execute(runnableFuture); return(runnableFuture); }
internal QueueingFuture(ExecutorCompletionService <T> enclosingInstance, IRunnableFuture <T> task) : base(task, null) { _enclosingInstance = enclosingInstance; _task = task; }