All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbehave.web.selenium.DisplayIdPool Maven / Gradle / Ivy

The newest version!
package org.jbehave.web.selenium;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import static java.util.Arrays.asList;

public class DisplayIdPool {

    private BlockingQueue queue;

    public DisplayIdPool(String... displays) {
        queue = new ArrayBlockingQueue(displays.length, false, asList(displays));
    }

    public String get() {
        try {
            return queue.take();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    public void returnToPool(String displayId) {
        try {
            queue.put(displayId);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy