Vert.x Concurrent

A selection of utilities from java.util.concurrent, in Vert.x-aware, non-blocking form

License

License

GroupId

GroupId

com.github.rworsnop
ArtifactId

ArtifactId

vertx-concurrent
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Vert.x Concurrent
A selection of utilities from java.util.concurrent, in Vert.x-aware, non-blocking form
Project URL

Project URL

https://github.com/rworsnop/vertx-concurrent
Source Code Management

Source Code Management

https://github.com/rworsnop/vertx-concurrent

Download vertx-concurrent

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.rworsnop/vertx-concurrent/ -->
<dependency>
    <groupId>com.github.rworsnop</groupId>
    <artifactId>vertx-concurrent</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.rworsnop/vertx-concurrent/
implementation 'com.github.rworsnop:vertx-concurrent:1.0.0'
// https://jarcasting.com/artifacts/com.github.rworsnop/vertx-concurrent/
implementation ("com.github.rworsnop:vertx-concurrent:1.0.0")
'com.github.rworsnop:vertx-concurrent:jar:1.0.0'
<dependency org="com.github.rworsnop" name="vertx-concurrent" rev="1.0.0">
  <artifact name="vertx-concurrent" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.rworsnop', module='vertx-concurrent', version='1.0.0')
)
libraryDependencies += "com.github.rworsnop" % "vertx-concurrent" % "1.0.0"
[com.github.rworsnop/vertx-concurrent "1.0.0"]

Dependencies

provided (2)

Group / Artifact Type Version
io.vertx : vertx-core jar 3.1.0
io.vertx : vertx-rx-java jar 3.1.0

test (2)

Group / Artifact Type Version
io.vertx : vertx-unit jar 3.1.0
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Vert.x Concurrent

Build Status

A selection of utilities from java.util.concurrent, in Vert.x-aware, non-blocking form.

See the api docs

Getting the library

Either grab the latest from the releases page or add a Maven dependency:

<dependency>
    <groupId>com.github.rworsnop</groupId>
    <artifactId>vertx-concurrent</artifactId>
    <version>1.0.0</version>
</dependency>

Examples

Semaphore

Semaphore semaphore = new Semaphore(50, vertx);
semaphore.acquire(10, ()->{
   // do some work
   semaphore.release(10);
}));
Semaphore semaphore = new Semaphore(50, vertx);
if (semaphore.tryAcquire(10)) {
    // do some work
    semaphore.release(10);
}
Semaphore semaphore = new Semaphore(50, vertx);
semaphore.tryAcquire(10, 30, SECONDS, success->{
    if (success){
        // do some work
        semaphore.release(10);
    } else {
        // timed out before we could acquire permits
    }
});
// Don't process more than 30,000 requests in a 10-second window
Semaphore semaphore = new Semaphore(30_000, vertx);
vertx.createHttpServer().requestHandler(req->{
    semaphore.acquire(()->req.response().end("Permits: " + semaphore.getAvailablePermits()));
    vertx.setTimer(10_000, id->semaphore.release());
}).listen(8082);

Versions

Version
1.0.0