Skip to content

Commit 2989b9f

Browse files
committed
Set version to 9.0.488
1 parent 1e7d95c commit 2989b9f

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog #
22

33

4+
## Version 9.0.488
5+
6+
Date: 2022-10-17
7+
8+
- Add more usability fixes on concurrencly limiter
9+
10+
11+
412
## Version 9.0.486
513

614
Date: 2022-10-17

build.clj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,21 @@
2929
{:class-dir class-dir
3030
:jar-file jar-file}))
3131

32+
3233
(defn compile [_]
3334
(b/javac {:src-dirs ["src"]
3435
:class-dir class-dir
3536
:basis basis
3637
:javac-opts ["-source" "11" "-target" "11" "-Xlint:unchecked"]}))
3738

39+
40+
(defn install [_]
41+
(b/install {:basis basis
42+
:lib lib
43+
:version version
44+
:jar-file jar-file
45+
:class-dir class-dir}))
46+
3847
(defn clojars [_]
3948
(b/process
4049
{:command-args ["mvn"

doc/user-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ A promise library for Clojure and ClojureScript.
99
Leiningen:
1010

1111
```clojure
12-
[funcool/promesa "9.0.486"]
12+
[funcool/promesa "9.0.488"]
1313
```
1414

1515
deps.edn:
1616

1717
```clojure
18-
funcool/promesa {:mvn/version "9.0.486"}
18+
funcool/promesa {:mvn/version "9.0.488"}
1919
```
2020

2121
On the JVM platform _promesa_ is built on top of *completable futures*

src/promesa/exec.cljc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,13 @@
475475
#?(:clj
476476
(defn concurrency-limiter
477477
"Create an instance of concurrencly limiter. EXPERIMENTAL"
478-
[& {:keys [executor concurrency queue-size on-run on-poll]
478+
[& {:keys [executor concurrency queue-size on-run on-poll on-queue]
479479
:or {executor *default-executor*
480480
concurrency 1
481481
queue-size Integer/MAX_VALUE}}]
482482
(let [^ExecutorService executor (resolve-executor executor)]
483483
(doto (ConcurrencyLimiter. executor (int concurrency) (int queue-size))
484+
(cond-> (fn? on-queue) (.setOnQueueCallback on-queue))
484485
(cond-> (fn? on-run) (.setOnRunCallback on-run))
485486
(cond-> (fn? on-poll) (.setOnPollCallback on-poll))))))
486487

src/promesa/exec/ConcurrencyLimiter.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class ConcurrencyLimiter extends AFn implements IObj {
4848
private final int maxQueueSize;
4949
private IPersistentMap metadata = PersistentArrayMap.EMPTY;
5050

51+
protected IFn onQueueCallback;
5152
protected IFn onRunCallback;
5253
protected IFn onPollCallback;
5354

@@ -61,6 +62,10 @@ public ConcurrencyLimiter(final ExecutorService executor,
6162
this.limit = new Semaphore(maxConcurrency);
6263
}
6364

65+
public void setOnQueueCallback(IFn f) {
66+
this.onQueueCallback = f;
67+
}
68+
6469
public void setOnRunCallback(IFn f) {
6570
this.onRunCallback = f;
6671
}
@@ -89,6 +94,10 @@ public CompletableFuture invoke(Object arg1) {
8994
return result;
9095
}
9196

97+
if (this.onQueueCallback != null) {
98+
this.onQueueCallback.invoke();
99+
}
100+
92101
this.executor.submit((Runnable)this);
93102
return result;
94103
}
@@ -196,10 +205,10 @@ public void run() {
196205
return;
197206
}
198207

199-
future.whenComplete((result, t) -> {
200-
if (t != null) {
208+
future.whenComplete((result, cause) -> {
209+
if (cause != null) {
201210
this.limiter.releaseAndSchedule();
202-
this.result.completeExceptionally((Throwable)t);
211+
this.result.completeExceptionally((Throwable)cause);
203212
} else {
204213
this.limiter.releaseAndSchedule();
205214
this.result.complete(result);

0 commit comments

Comments
 (0)