The aim is to be extremely low latency with near zero GC overhead.
An example of how to use one of our low latency bounded queues.
// writer thread
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
queue.add(1);
}
});
// reader thread
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
final int value = queue.take();
}
});
We are hosted at [Maven Central] (http://search.maven.org), one of the quickest ways to get up and running is to add this Maven dependency to your pom file :
<dependency>
<groupId>uk.co.boundedbuffer</groupId>
<artifactId>low-latency-primitive-concurrent-queues</artifactId>
<version>1.0.1</version>
<dependency>
Having trouble ? Check out our documentation at [JavaDoc] (http://robaustin.github.io/low-latency-primitive-concurrent-queues/apidocs/)
Yes - it's thread safe, but you are limited to using just two threads per queue instance, One producer thread and a consumer thread.
The queues take advantage of the Unsafe.putOrderedX(), which provides non-blocking code with guaranteed writes. These writes will not be re-ordered by instruction reordering, they use a faster store-store barrier, rather than the the slower store-load barrier ( which is used when doing a volatile write ). One of the trade offs with this improved performance is the visibility of the reads and writes between cores.
Contributors are extremely welcome, just fork this project, make your changes, and we'd be happy to review your pull-request.
Having Problems ? Contact [email protected] and we’ll help you sort it out.
If you are interest in low latency java, see my blog at [http://robsjava.blogspot.co.uk] (http://robsjava.blogspot.co.uk)