public Future <T> submit <T>(Runnable task) { if (task == null) { throw new NullReferenceException(); } RunnableFuture <T> ftask = newTaskFor <T>(task, default(T)); return(ftask); }
public virtual Future <V> Submit(Runnable task, V result) { if (task == null) { throw new NullPointerException(); } RunnableFuture <V> f = NewTaskFor(task, result); Executor.Execute(new QueueingFuture(this, f)); return(f); }
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ public Future <T> submit <T>(Callable <T> task) where T : class { if (task == null) { throw new NullReferenceException(); } RunnableFuture <T> ftask = newTaskFor(task); Execute(ftask); return(ftask); }
/// <summary> /// 提交任务 /// </summary> /// <param name="task"></param> /// <param name="result"></param> /// <returns></returns> public Future <V> Submit(Runnable task, V result) { if (task == null) { throw new NullReferenceException(); } RunnableFuture <V> f = newTaskFor(task, result); executor.Execute(new QueueingFuture(f, completionQueue)); return(f); }
/// <exception cref="RejectedExecutionException"> {@inheritDoc} </exception> /// <exception cref="NullPointerException"> {@inheritDoc} </exception> public virtual Future <T> submit <T>(Callable <T> task) { if (task == null) { throw new NullPointerException(); } RunnableFuture <T> ftask = NewTaskFor(task); Execute(ftask); return(ftask); }
/// <exception cref="RejectedExecutionException"> {@inheritDoc} </exception> /// <exception cref="NullPointerException"> {@inheritDoc} </exception> //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: public Future<?> submit(Runnable task) public virtual Future <?> Submit(Runnable task) { if (task == null) { throw new NullPointerException(); } RunnableFuture <Void> ftask = NewTaskFor(task, null); Execute(ftask); return(ftask); }
public List <Future <T> > invokeAll <T>(IEnumerable <Callable <T> > tasks) { if (tasks == null) { throw new NullReferenceException(); } List <Future <T> > futures = new List <Future <T> >(tasks.Count()); bool done = false; try { foreach (var t in tasks) { RunnableFuture <T> f = newTaskFor(t); futures.Add(f); Execute(f); } for (int i = 0, size = futures.Count(); i < size; i++) { Future <T> f = futures[i]; if (!f.isDone()) { try { f.get(); } catch (CancellationException ignore) { } catch (ExecutionException ignore) { } } } done = true; return(futures); } finally { if (!done) { for (int i = 0, size = futures.Count(); i < size; i++) { futures[i].cancel(true); } } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException public virtual List <Future <T> > invokeAll <T, T1>(Collection <T1> tasks) where T1 : Callable <T> { if (tasks == null) { throw new NullPointerException(); } List <Future <T> > futures = new List <Future <T> >(tasks.Size()); bool done = false; try { foreach (Callable <T> t in tasks) { RunnableFuture <T> f = NewTaskFor(t); futures.Add(f); Execute(f); } for (int i = 0, size = futures.Size(); i < size; i++) { Future <T> f = futures.Get(i); if (!f.Done) { try { f.Get(); } catch (CancellationException) { } catch (ExecutionException) { } } } done = true; return(futures); } finally { if (!done) { for (int i = 0, size = futures.Size(); i < size; i++) { futures.Get(i).Cancel(true); } } } }
internal QueueingFuture(ExecutorCompletionService <V> outerInstance, RunnableFuture <V> task) : base(task, null) { this.OuterInstance = outerInstance; this.Task = task; }
public QueueingFuture(RunnableFuture <V> task, BlockingQueue <Future <V> > completionQueue) : base(task, default(V)) { this.task = task; }