Skip to content

Commit

Permalink
Clean up code comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jan 3, 2024
1 parent 596462c commit 448c6e5
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ public class CallbackDispatcher {
private final AtomicInteger nextAvailableRequestId = new AtomicInteger(0);

/**
* Storage of Futures to handle responses. Map key is callback id, which starts from 1.<br>
* Each future is a promise for every submitted by user request.<br>
* Note: Protobuf packet contains callback ID as uint32, but it stores data as a bit field.<br>
* Negative java values would be shown as positive on rust side. Meanwhile, no data loss happen,
* because callback ID remains unique.
* Storage of Futures to handle responses. Map key is callback id, which starts from 0. The value
* is a CompletableFuture that is returned to the user and completed when the request is done.
*
* <p>Note: Protobuf packet contains callback ID as uint32, but it stores data as a bit field.
* Negative Java values would be shown as positive on Rust side. There is no data loss, because
* callback ID remains unique.
*/
private final ConcurrentHashMap<Integer, CompletableFuture<Response>> responses =
new ConcurrentHashMap<>();

/**
* Storage of freed callback IDs. It is needed to avoid occupying an ID being used and to speed up
* search for a next free ID.<br>
* search for a next free ID.
*/
// TODO: Optimize to avoid growing up to 2e32 (16 Gb) https://github.com/aws/babushka/issues/704
private final ConcurrentLinkedQueue<Integer> freeRequestIds = new ConcurrentLinkedQueue<>();
Expand Down

0 comments on commit 448c6e5

Please sign in to comment.