// Path: netty-http/src/main/java/http/worker/SearchWorker.java
// public class SearchWorker extends ThreadPoolExecutor {
//     private final static Logger logger = LoggerFactory.getLogger(SearchWorker.class);
//     private static SearchWorker instance;
// 
//     public SearchWorker(int size, String name, BlockingQueue blockingQueue) {
//         super(size, size+5, 0L, TimeUnit.MILLISECONDS, blockingQueue, new WorkerThread(name));
//     }
// 
//     @Override
//     protected void beforeExecute(Thread t, Runnable r) {
//         logger.info("start to exectue: " + t);
//         super.beforeExecute(t, r);
//     }
// 
//     @Override
//     protected void afterExecute(Runnable r, Throwable t) {
//         super.afterExecute(r, t);
//         logger.info("after to exectue: " + t);
//     }
// 
//     public INotifyingFuture doSearch(SearchRequest request) {
//         SearchingFuture future = new SearchingFuture(request);
//         future.setExecutor(this);
//         future.run();
//         return future;
//     }
// 
//     public String monitorInfo() {
//         StringBuilder result = new StringBuilder(100);
//         result.append("\r\n QueueSize :" + this.getQueue().size());
//         result.append("ThreadCount :" + this.getPoolSize() + "\r\n");
//         return result.toString();
//     }
// }


import http.worker.SearchWorker;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;

    /**
     * Atomically executes the task only one time.
     */
    protected void notifyListenerOnce(){
        if(!this.executed.getAndSet(true)){
            notifyListener();
        }
    }

    protected void notifyListener() {
        this.executor.submit(new TaskCompletionRunner<V>(delegateFuture(),this.listener));
    }

    /**
     * @return the future that was processed.
     */
    protected RunnableFuture<V> delegateFuture(){
        return this;
    }

    @Override
    public void setListener(IFutureListener<V> listener, ExecutorService executor) {
        setExecutor(executor);
        setListener(listener);
    }

    public void setExecutor(ExecutorService executor) {
        this.executor = executor;
    }


// Path: netty-http/src/main/java/http/worker/SearchWorker.java
// public class SearchWorker extends ThreadPoolExecutor {
//     private final static Logger logger = LoggerFactory.getLogger(SearchWorker.class);
//     private static SearchWorker instance;
// 
//     public SearchWorker(int size, String name, BlockingQueue blockingQueue) {
//         super(size, size+5, 0L, TimeUnit.MILLISECONDS, blockingQueue, new WorkerThread(name));
//     }
// 
//     @Override
//     protected void beforeExecute(Thread t, Runnable r) {
//         logger.info("start to exectue: " + t);
//         super.beforeExecute(t, r);
//     }
// 
//     @Override
//     protected void afterExecute(Runnable r, Throwable t) {
//         super.afterExecute(r, t);
//         logger.info("after to exectue: " + t);
//     }
// 
//     public INotifyingFuture doSearch(SearchRequest request) {
//         SearchingFuture future = new SearchingFuture(request);
//         future.setExecutor(this);
//         future.run();
//         return future;
//     }
// 
//     public String monitorInfo() {
//         StringBuilder result = new StringBuilder(100);
//         result.append("\r\n QueueSize :" + this.getQueue().size());
//         result.append("ThreadCount :" + this.getPoolSize() + "\r\n");
//         return result.toString();
//     }
// }


// Path: netty-http/src/main/java/http/worker/notifyexecutor/SearchingFuture.java
import http.worker.SearchWorker;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;

    /**
     * Atomically executes the task only one time.
     */
    protected void notifyListenerOnce(){
        if(!this.executed.getAndSet(true)){
            notifyListener();
        }
    }

    protected void notifyListener() {
        this.executor.submit(new TaskCompletionRunner<V>(delegateFuture(),this.listener));
    }

    /**
     * @return the future that was processed.
     */
    protected RunnableFuture<V> delegateFuture(){
        return this;
    }

    @Override
    public void setListener(IFutureListener<V> listener, ExecutorService executor) {
        setExecutor(executor);
        setListener(listener);
    }

    public void setExecutor(ExecutorService executor) {
        this.executor = executor;
    }


    @Override
