Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 2.32 KB

File metadata and controls

65 lines (44 loc) · 2.32 KB

Faster than ArrayBlockingQueue

PerformanceComparison

Aim

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();
    }
});


Maven Central

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>

JavaDoc

Having trouble ? Check out our documentation at [JavaDoc] (http://robaustin.github.io/low-latency-primitive-concurrent-queues/apidocs/)

Is this Queue Thread Safe ?

Yes - it's thread safe, but you are limited to using just two threads per queue instance, One producer thread and a consumer thread.

Why am I limited to only using just two threads ?

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.

Licence

Apache v2

Contributors

Contributors are extremely welcome, just fork this project, make your changes, and we'd be happy to review your pull-request.

Support or Contact

Having Problems ? Contact [email protected] and we’ll help you sort it out.

Blog

If you are interest in low latency java, see my blog at [http://robsjava.blogspot.co.uk] (http://robsjava.blogspot.co.uk)