internal NamedTask(ICallable <V> c) : base(c) { if (!(c is MulticoreWrapper.CallableJob)) { throw new AssertionError("Should have gotten a CallableJob"); } MulticoreWrapper.CallableJob <I, O> callable = (MulticoreWrapper.CallableJob <I, O>)c; item = callable.item; }
/// <summary>Allocate instance to a process and return.</summary> /// <remarks> /// Allocate instance to a process and return. This call blocks until item /// can be assigned to a thread. /// </remarks> /// <param name="item">Input to a Processor</param> /// <exception cref="Java.Util.Concurrent.RejectedExecutionException"> /// -- A RuntimeException when there is an /// uncaught exception in the queue. Resolution is for the calling class to shutdown /// the wrapper and create a new threadpool. /// </exception> public virtual void Put(I item) { lock (this) { int procId = GetProcessor(); if (procId == null) { throw new RejectedExecutionException("Couldn't submit item to threadpool: " + item); } int itemId = submittedItemCounter++; MulticoreWrapper.CallableJob <I, O> job = new MulticoreWrapper.CallableJob <I, O>(item, itemId, processorList[procId], procId, callback); threadPool.Submit(job); } }