Skip to content

Commit

Permalink
change priority queue
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyuxia committed Dec 2, 2024
1 parent 7475904 commit ca54919
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import javax.annotation.concurrent.ThreadSafe;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.TimeUnit;

/** A blocking queue channel that can receive requests and send responses. */
Expand All @@ -33,10 +33,7 @@ public final class RequestChannel {
private final BlockingQueue<RpcRequest> requestQueue;

public RequestChannel(int queueCapacity) {
this.requestQueue =
new PriorityBlockingQueue<>(
queueCapacity,
(req1, req2) -> Integer.compare(req2.getPriority(), req1.getPriority()));
this.requestQueue = new ArrayBlockingQueue<>(queueCapacity);
}

/**
Expand Down

0 comments on commit ca54919

Please sign in to comment.