Skip to content

Commit

Permalink
Move lock outside the try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
OptimumCode committed Sep 12, 2024
1 parent 0bfb9d2 commit 5e8977b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ class Channel(
*/
private inline fun <T> sendWithLock(block: CompletableFuture<T>.() -> Unit): CompletableFuture<T> =
CompletableFuture<T>().apply {
lock.lock()
try {
lock.lock()
limiter.acquire().also { waited_time ->
if(waited_time > 0) {
logger.info { "Waited for ${waited_time} seconds." }
limiter.acquire().also { waitedTime ->
if(waitedTime > 0) {
logger.info { "Waited for $waitedTime seconds." }
}
}

Expand Down

0 comments on commit 5e8977b

Please sign in to comment.