2 * Copyright (c) 2017 Cisco Systems, Inc. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.lispflowmapping.neutron.intenthandler;
10 import com.google.common.util.concurrent.ListeningExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
13 import java.util.concurrent.Executors;
16 * Created by Shakib Ahmed on 1/24/17.
18 public class IntentHandlerAsyncExecutorProvider {
19 private static ListeningExecutorService listeningExecutorService;
21 private static final int EXTRA_THREADS_TO_HANDLE_VPP_LISTENER = 1;
23 private static IntentHandlerAsyncExecutorProvider intentHandlerAsyncExecutorProvider;
25 private IntentHandlerAsyncExecutorProvider() {
26 listeningExecutorService = MoreExecutors
27 .listeningDecorator(Executors.newFixedThreadPool(EXTRA_THREADS_TO_HANDLE_VPP_LISTENER));
30 public static synchronized IntentHandlerAsyncExecutorProvider getInstace() {
31 if (intentHandlerAsyncExecutorProvider == null) {
32 intentHandlerAsyncExecutorProvider = new IntentHandlerAsyncExecutorProvider();
34 return intentHandlerAsyncExecutorProvider;
37 public synchronized ListeningExecutorService getExecutor() {
38 return listeningExecutorService;
42 listeningExecutorService.shutdown();