2 * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. 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.openflowjava.protocol.impl.core.connection;
10 import java.util.HashMap;
13 final class OutboundQueueCache {
14 private static final OutboundQueueCache INSTANCE = new OutboundQueueCache();
16 private final Map<Integer, OutboundQueueCacheSlice> slices = new HashMap<>();
18 private OutboundQueueCache() {
22 static OutboundQueueCache getInstance() {
26 synchronized OutboundQueueCacheSlice getSlice(final int queueSize) {
27 final OutboundQueueCacheSlice oldSlice = slices.get(queueSize);
28 if (oldSlice != null) {
33 final OutboundQueueCacheSlice newSlice = new OutboundQueueCacheSlice(queueSize);
34 slices.put(queueSize, newSlice);
38 synchronized void putSlice(final OutboundQueueCacheSlice slice) {
40 slices.remove(slice.getQueueSize());