List of usage examples for java.util.concurrent LinkedBlockingDeque LinkedBlockingDeque
public LinkedBlockingDeque()
From source file:Main.java
public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque() { return new LinkedBlockingDeque<E>(); }
From source file:Main.java
/** * Given any of the known collection types, this method will return an instance of the collection. * @param collectionType the type of the collection * @return the collection instance//from ww w .ja va2s. co m */ public static Collection<?> getCollection(Class<?> collectionType) { if (HashSet.class.equals(collectionType)) { return new HashSet<Object>(); } else if (TreeSet.class.equals(collectionType)) { return new TreeSet<Object>(); } else if (CopyOnWriteArraySet.class.equals(collectionType)) { return new CopyOnWriteArraySet<Object>(); } else if (LinkedHashSet.class.equals(collectionType)) { return new LinkedHashSet<Object>(); } else if (ArrayList.class.equals(collectionType)) { return new ArrayList<Object>(); } else if (LinkedList.class.equals(collectionType)) { return new LinkedList<Object>(); } else if (Vector.class.equals(collectionType)) { return new Vector<Object>(); } else if (Stack.class.equals(collectionType)) { return new Stack<Object>(); } else if (PriorityQueue.class.equals(collectionType)) { return new PriorityQueue<Object>(); } else if (PriorityBlockingQueue.class.equals(collectionType)) { return new PriorityBlockingQueue<Object>(); } else if (ArrayDeque.class.equals(collectionType)) { return new ArrayDeque<Object>(); } else if (ConcurrentLinkedQueue.class.equals(collectionType)) { return new ConcurrentLinkedQueue<Object>(); } else if (LinkedBlockingQueue.class.equals(collectionType)) { return new LinkedBlockingQueue<Object>(); } else if (LinkedBlockingDeque.class.equals(collectionType)) { return new LinkedBlockingDeque<Object>(); } else if (List.class.equals(collectionType)) { return new LinkedList<Object>(); } else if (Set.class.equals(collectionType)) { return new HashSet<Object>(); } else if (Queue.class.equals(collectionType)) { return new PriorityQueue<Object>(); } else if (Deque.class.equals(collectionType)) { return new ArrayDeque<Object>(); } else if (Collection.class.equals(collectionType)) { return new LinkedList<Object>(); } throw new IllegalArgumentException("Unsupported collection type: " + collectionType); }
From source file:tools.datasync.db2db.sync.SeedQueue.java
public SeedQueue() { seedIn = new LinkedBlockingDeque<Runnable>(); seedOut = new LinkedBlockingDeque<Runnable>(); }
From source file:org.statmantis.util.CollectionUtils.java
@SuppressWarnings("unchecked") public static <T, U extends Collection<T>> U newCollectionFromInterface(Class<U> collectionClass) { if (BlockingDeque.class.isAssignableFrom(collectionClass)) { return (U) new LinkedBlockingDeque<T>(); } else if (BlockingQueue.class.isAssignableFrom(collectionClass)) { return (U) new LinkedBlockingQueue<T>(); } else if (Queue.class.isAssignableFrom(collectionClass)) { return (U) new ArrayDeque<T>(); } else if (List.class.isAssignableFrom(collectionClass)) { return (U) new ArrayList<T>(); } else if (SortedSet.class.isAssignableFrom(collectionClass)) { return (U) new TreeSet<T>(); } else if (Set.class.isAssignableFrom(collectionClass)) { return (U) new HashSet<T>(); } else if (Collection.class.isAssignableFrom(collectionClass)) { return (U) new ArrayList<T>(); } else {//from w ww .jav a 2s . c om throw new BaseRuntimeException("Unrecognized interface: " + collectionClass); } }
From source file:enmasse.queue.scheduler.Artemis.java
public static Future<Broker> create(Vertx vertx, ProtonConnection connection) { CompletableFuture<Broker> promise = new CompletableFuture<>(); connection.sessionOpenHandler(ProtonSession::open); BlockingQueue<Message> replies = new LinkedBlockingDeque<>(); ProtonSender sender = connection.createSender("activemq.management"); sender.openHandler(result -> {//from w w w .j a v a 2 s . co m ProtonReceiver receiver = connection.createReceiver("activemq.management"); Source source = new Source(); source.setDynamic(true); receiver.setSource(source); receiver.openHandler(h -> { promise.complete(new Artemis(vertx, sender, h.result().getRemoteSource().getAddress(), replies)); }); receiver.handler(((protonDelivery, message) -> { try { replies.put(message); ProtonHelper.accepted(protonDelivery, true); } catch (Exception e) { ProtonHelper.rejected(protonDelivery, true); } })); receiver.open(); }); sender.open(); return promise; }
From source file:org.wso2.andes.kernel.MessageContentRemoverTask.java
/** * Setup the content deletion task with the reference to MessageStore and * DurableStoreConnection to message store * @param messageStore MessageStore//from w ww . j a v a2s.c o m */ public MessageContentRemoverTask(MessageStore messageStore) { this.messageStore = messageStore; messageIdToDeleteQueue = new LinkedBlockingDeque<Long>(); }
From source file:org.calrissian.flowmix.core.support.window.Window.java
public Window(String groupedIndex) { events = new LinkedBlockingDeque<WindowItem>(); this.groupedIndex = groupedIndex; }
From source file:edu.iu.harp.schdynamic.DynamicScheduler.java
public DynamicScheduler(List<T> tasks) { inputQueue = new LinkedBlockingDeque<>(); outputQueue = new LinkedBlockingQueue<>(); threads = null;//from w w w . jav a 2 s.c om inputCount = 0; outputCount = 0; errorCount = 0; isRunning = false; isPausing = false; barrier1 = new Semaphore(0); numTaskMonitors = tasks.size(); this.tasks = tasks; taskMonitors = new ArrayList<>(); for (T task : tasks) { taskMonitors.add(new TaskMonitor<>(inputQueue, outputQueue, task, barrier1)); } }
From source file:org.batoo.jpa.core.pool.GenericPool.java
/** * @param factory//from w w w . j a va2 s .c o m * the factory of the pool * * @since $version * @author hceylan */ public GenericPool(PoolableObjectFactory<T> factory) { super(); this.factory = factory; this.pool = new LinkedBlockingDeque<T>(); this.active = true; }
From source file:com.twosigma.beaker.core.rest.RecentMenuRest.java
@Inject public RecentMenuRest(BeakerConfig bkConfig, GeneralUtils utils) { this.utils = utils; this.recentDocumentsFile = Paths.get(bkConfig.getRecentNotebooksFileUrl()); this.recentDocuments = new LinkedBlockingDeque<>(); // read from file -> recentDocuments List<String> lines = new ArrayList<>(); if (Files.exists(recentDocumentsFile)) { try {/* ww w . j a va2 s .c om*/ lines = Files.readAllLines(recentDocumentsFile, StandardCharsets.UTF_8); } catch (IOException ex) { logger.warn("Failed to get recent documents", ex); } } for (String line : lines) { addRecentDocument(line.trim()); } }