1 /** 2 * Logback: the reliable, generic, fast and flexible logging framework. 3 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 4 * 5 * This program and the accompanying materials are dual-licensed under 6 * either the terms of the Eclipse Public License v1.0 as published by 7 * the Eclipse Foundation 8 * 9 * or (per the licensee's choosing) 10 * 11 * under the terms of the GNU Lesser General Public License version 2.1 12 * as published by the Free Software Foundation. 13 */ 14 package ch.qos.logback.core.net; 15 16 import java.util.concurrent.ArrayBlockingQueue; 17 import java.util.concurrent.LinkedBlockingDeque; 18 19 /** 20 * Factory for {@link java.util.Queue} instances. 21 * 22 * @author Sebastian Gröbler 23 */ 24 public class QueueFactory { 25 26 /** 27 * Creates a new {@link LinkedBlockingDeque} with the given {@code capacity}. In 28 * case the given capacity is smaller than one it will automatically be 29 * converted to one. 30 * 31 * @param capacity the capacity to use for the queue 32 * @param <E> the type of elements held in the queue 33 * @return a new instance of {@link ArrayBlockingQueue} 34 */ 35 public <E> LinkedBlockingDeque<E> newLinkedBlockingDeque(int capacity) { 36 final int actualCapacity = capacity < 1 ? 1 : capacity; 37 return new LinkedBlockingDeque<E>(actualCapacity); 38 } 39 }