mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8263561: Re-examine uses of LinkedList
Reviewed-by: redestad
This commit is contained in:
parent
6a3f8343bc
commit
249d641889
9 changed files with 45 additions and 47 deletions
|
@ -40,14 +40,14 @@ import java.util.*;
|
|||
|
||||
abstract class AbstractPoller implements Runnable {
|
||||
|
||||
// list of requests pending to the poller thread
|
||||
private final LinkedList<Request> requestList;
|
||||
// requests pending to the poller thread
|
||||
private final ArrayDeque<Request> requests;
|
||||
|
||||
// set to true when shutdown
|
||||
private boolean shutdown;
|
||||
|
||||
protected AbstractPoller() {
|
||||
this.requestList = new LinkedList<>();
|
||||
this.requests = new ArrayDeque<>();
|
||||
this.shutdown = false;
|
||||
}
|
||||
|
||||
|
@ -216,11 +216,11 @@ abstract class AbstractPoller implements Runnable {
|
|||
private Object invoke(RequestType type, Object... params) throws IOException {
|
||||
// submit request
|
||||
Request req = new Request(type, params);
|
||||
synchronized (requestList) {
|
||||
synchronized (requests) {
|
||||
if (shutdown) {
|
||||
throw new ClosedWatchServiceException();
|
||||
}
|
||||
requestList.add(req);
|
||||
requests.add(req);
|
||||
|
||||
// wakeup thread
|
||||
wakeup();
|
||||
|
@ -243,9 +243,9 @@ abstract class AbstractPoller implements Runnable {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
boolean processRequests() {
|
||||
synchronized (requestList) {
|
||||
synchronized (requests) {
|
||||
Request req;
|
||||
while ((req = requestList.poll()) != null) {
|
||||
while ((req = requests.poll()) != null) {
|
||||
// if in process of shutdown then reject request
|
||||
if (shutdown) {
|
||||
req.release(new ClosedWatchServiceException());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue