Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
add method to get remaining ThreadPoolTaskExecutor's queue capacity (#20
Browse files Browse the repository at this point in the history
)

Co-authored-by: Stephen Tobayiwa <[email protected]>
  • Loading branch information
stobayiwa and Stephen Tobayiwa authored Jan 26, 2024
1 parent bd2512e commit c3be46c
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,19 @@ public void shutdown() {
messageProcessingExecutor.getThreadPoolExecutor().awaitTermination(10, TimeUnit.SECONDS);
}
}
/**
* Returns the number of elements that the {@link #messageProcessingExecutor} can accept
* <p>
* This method should only be used in a single threaded environment, since it is possible that
* in a multi-threaded environment the number of free slots changes between the call to this method
*
* @return Remaining queue capacity
*/
public int getRemainingCapacity() {
return messageProcessingExecutor
.getThreadPoolExecutor()
.getQueue()
.remainingCapacity();
}

}

0 comments on commit c3be46c

Please sign in to comment.