Beispiel #1
0
 /**
  * Schedule the given command for execution in another thread. The command is expected to do its
  * own exception handling.
  */
 public void schedule(Runnable command) {
   try {
     service.execute(command);
   } catch (RejectedExecutionException ex) {
     if (controller.getException() != null) {
       throw new RejectedExecutionException(controller.getException());
     }
     throw ex;
   }
 }
Beispiel #2
0
 /**
  * Constructor for <code>JobManager</code> with controller and job queue of the specified capacity
  *
  * @param controller the born/die controller
  * @param queueCapacity the queue size to queue jobs, 0 for unlimited queue
  */
 public JobManager(BornDieController<Col> controller, int queueCapacity) {
   this.controller = controller;
   this.service = createExecutorService(controller.getConfig().getMaxThreads(), queueCapacity);
 }
Beispiel #3
0
 /** Start scheduling jobs for processing. */
 public void terminate() throws Exception {
   if (controller.getException() != null) {
     throw controller.getException();
   }
   service.awaitTermination(0, TimeUnit.MILLISECONDS);
 }
Beispiel #4
0
 /**
  * Adds the pairing job to the job queue
  *
  * @param pairingJob the job to add to the queue
  */
 public void addJob(PairingJob<Col> pairingJob) throws InterruptedException {
   schedule(pairingJob);
   if (controller.getDebugger().doDebug()) {
     controller.getDebugger().notifyPairingQueued(pairingJob);
   }
 }