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;
12 import java.util.concurrent.Executors;
15 * Created by Shakib Ahmed on 1/24/17.
17 public final class IntentHandlerAsyncExecutorProvider {
18 private static ListeningExecutorService listeningExecutorService;
20 private static final int EXTRA_THREADS_TO_HANDLE_VPP_LISTENER = 1;
22 private static IntentHandlerAsyncExecutorProvider intentHandlerAsyncExecutorProvider;
24 private IntentHandlerAsyncExecutorProvider() {
25 listeningExecutorService = MoreExecutors
26 .listeningDecorator(Executors.newFixedThreadPool(EXTRA_THREADS_TO_HANDLE_VPP_LISTENER));
29 public static synchronized IntentHandlerAsyncExecutorProvider getInstace() {
30 if (intentHandlerAsyncExecutorProvider == null) {
31 intentHandlerAsyncExecutorProvider = new IntentHandlerAsyncExecutorProvider();
33 return intentHandlerAsyncExecutorProvider;
36 public synchronized ListeningExecutorService getExecutor() {
37 return listeningExecutorService;
41 listeningExecutorService.shutdown();