// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.collections; import java.util.Iterator; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; /** * @author baldersheim * TODO: remove on vespa 7 or before * Use com.yahoo.yolean.concurrent.ConcurrentResourcePool instead. */ @Deprecated public class ConcurrentResourcePool implements Iterable { private final Queue pool = new ConcurrentLinkedQueue<>(); private final ResourceFactory factory; public ConcurrentResourcePool(ResourceFactory factory) { this.factory = factory; } public final T alloc() { final T e = pool.poll(); return e != null ? e : factory.create(); } public final void free(T e) { pool.offer(e); } @Override public Iterator iterator() { return pool.iterator(); } }