/**
 * @license
 * Copyright 2019 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.util.concurrent;

import foam.core.Agency;
import foam.core.ContextAgent;
import foam.core.X;

/**
* An Aynchronous implementation of the AssemblyLine interface.
* Uses the threadpool to avoid blocking the caller.
**/
public class AsyncAssemblyLine
 extends SyncAssemblyLine
{
 protected Agency pool_;

 public AsyncAssemblyLine(X x) {
   pool_ = (Agency) x.get("threadpool");
 }

 public void enqueue(Assembly job) {
   final Assembly previous;

   synchronized ( startLock_ ) {
     previous = q_;
     q_ = job;
     job.startJob();
   }

   pool_.submit(null, new ContextAgent() { public void execute(X x) {
     job.executeJob();

     if ( previous != null ) previous.waitToComplete();

     synchronized ( endLock_ ) {
       job.endJob();
       job.complete();
     }

     // Isn't required, but helps GC last entry.
     synchronized ( startLock_ ) {
       // If I'm still the only job in the queue, then remove me
       if ( q_ == job ) q_ = null;
     }
   }}, "SyncAssemblyLine");
 }
}

@@ -499,17 +499,17 @@
 (%22thread
-p
+P
 ool%22);%0A 

Fix service name typo.