org.hibernate.search.batchindexing.impl.ProducerConsumerQueue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-orm Show documentation
Show all versions of hibernate-search-orm Show documentation
Hibernate Search integration with Hibernate Core
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.search.batchindexing.impl;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Implements a blocking queue capable of storing
* a "poison" token to signal consumer threads
* that the task is finished.
*
* @author Sanne Grinovero
*/
public class ProducerConsumerQueue {
private static final int DEFAULT_BUFF_LENGTH = 1000;
private static final Object exitToken = new Object();
//doesn't use here as exitToken needs to be put in the queue too:
private final BlockingQueue