< prev index next >
src/java.base/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -30,11 +30,10 @@
*/
package sun.nio.ch;
import java.io.IOException;
-import java.io.FileDescriptor;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
class KQueueSelectorImpl
@@ -49,27 +48,27 @@
// Count of registered descriptors (including interrupt)
private int totalChannels;
// Map from a file descriptor to an entry containing the selection key
- private HashMap<Integer,MapEntry> fdMap;
+ private final HashMap<Integer,MapEntry> fdMap;
// True if this Selector has been closed
private boolean closed = false;
// Lock for interrupt triggering and clearing
- private Object interruptLock = new Object();
+ private final Object interruptLock = new Object();
private boolean interruptTriggered = false;
// used by updateSelectedKeys to handle cases where the same file
// descriptor is polled by more than one filter
private long updateCount;
// Used to map file descriptors to a selection key and "update count"
// (see updateSelectedKeys for usage).
private static class MapEntry {
- SelectionKeyImpl ski;
+ final SelectionKeyImpl ski;
long updateCount;
MapEntry(SelectionKeyImpl ski) {
this.ski = ski;
}
}
@@ -197,11 +196,11 @@
FileDispatcherImpl.closeIntFD(fd0);
FileDispatcherImpl.closeIntFD(fd1);
if (kqueueWrapper != null) {
kqueueWrapper.close();
kqueueWrapper = null;
- selectedKeys = null;
+ selectedKeys.clear();
// Deregister channels
Iterator<SelectionKey> i = keys.iterator();
while (i.hasNext()) {
SelectionKeyImpl ski = (SelectionKeyImpl)i.next();
@@ -234,11 +233,11 @@
fdMap.remove(Integer.valueOf(fd));
kqueueWrapper.release(ski.channel);
totalChannels--;
keys.remove(ski);
selectedKeys.remove(ski);
- deregister((AbstractSelectionKey)ski);
+ deregister(ski);
SelectableChannel selch = ski.channel();
if (!selch.isOpen() && !selch.isRegistered())
((SelChImpl)selch).kill();
}
< prev index next >