Skip to content

hadielmougy/JBlockingBuffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JBlockingBuffer

Concurrent blocking buffer

<dependency>
  <groupId>io.github</groupId>
  <artifactId>jblockingbuffer</artifactId>
  <version>1.0</version>
</dependency>

Buffer by time

// buffer size -1 means unlimited size
BlockingBuffer<Integer> buffer = new BlockingBuffer<>(-1, Duration.ofMillis(500));
buffer.add(1);
var list = buffer.get();

Buffer by size and time (whatever happens first)

BlockingBuffer<Integer> buffer = new BlockingBuffer<>(10, Duration.ofMillis(500));
buffer.add(1);
// will release after 500 millis
var list = buffer.get();

defaults

  • size is 10
  • time is 100 millis