use of java.nio.channels.spi.AbstractSelectionKey in project robovm by robovm.
the class SelectorImpl method doCancel.
/**
* Removes cancelled keys from the key set and selected key set, and
* unregisters the corresponding channels. Returns the number of keys
* removed from the selected key set.
*/
private int doCancel() {
int deselected = 0;
Set<SelectionKey> cancelledKeys = cancelledKeys();
synchronized (cancelledKeys) {
if (cancelledKeys.size() > 0) {
for (SelectionKey currentKey : cancelledKeys) {
mutableKeys.remove(currentKey);
deregister((AbstractSelectionKey) currentKey);
if (mutableSelectedKeys.remove(currentKey)) {
deselected++;
}
}
cancelledKeys.clear();
}
}
return deselected;
}
use of java.nio.channels.spi.AbstractSelectionKey in project robovm by robovm.
the class SelectorImpl method implCloseSelector.
@Override
protected void implCloseSelector() throws IOException {
wakeup();
synchronized (this) {
synchronized (unmodifiableKeys) {
synchronized (selectedKeys) {
IoUtils.close(wakeupIn);
IoUtils.close(wakeupOut);
doCancel();
for (SelectionKey sk : mutableKeys) {
deregister((AbstractSelectionKey) sk);
}
}
}
}
}
use of java.nio.channels.spi.AbstractSelectionKey in project XobotOS by xamarin.
the class SelectorImpl method doCancel.
/**
* Removes cancelled keys from the key set and selected key set, and
* deregisters the corresponding channels. Returns the number of keys
* removed from the selected key set.
*/
private int doCancel() {
int deselected = 0;
Set<SelectionKey> cancelledKeys = cancelledKeys();
synchronized (cancelledKeys) {
if (cancelledKeys.size() > 0) {
for (SelectionKey currentKey : cancelledKeys) {
mutableKeys.remove(currentKey);
deregister((AbstractSelectionKey) currentKey);
if (mutableSelectedKeys.remove(currentKey)) {
deselected++;
}
}
cancelledKeys.clear();
}
}
return deselected;
}
use of java.nio.channels.spi.AbstractSelectionKey in project j2objc by google.
the class SelectorImpl method implCloseSelector.
@Override
protected void implCloseSelector() throws IOException {
wakeup();
synchronized (this) {
synchronized (unmodifiableKeys) {
synchronized (selectedKeys) {
IoUtils.close(wakeupIn);
IoUtils.close(wakeupOut);
doCancel();
for (SelectionKey sk : mutableKeys) {
deregister((AbstractSelectionKey) sk);
}
}
}
}
}
use of java.nio.channels.spi.AbstractSelectionKey in project j2objc by google.
the class SelectorImpl method doCancel.
/**
* Removes cancelled keys from the key set and selected key set, and
* unregisters the corresponding channels. Returns the number of keys
* removed from the selected key set.
*/
private int doCancel() {
int deselected = 0;
Set<SelectionKey> cancelledKeys = cancelledKeys();
synchronized (cancelledKeys) {
if (cancelledKeys.size() > 0) {
for (SelectionKey currentKey : cancelledKeys) {
mutableKeys.remove(currentKey);
deregister((AbstractSelectionKey) currentKey);
if (mutableSelectedKeys.remove(currentKey)) {
deselected++;
}
}
cancelledKeys.clear();
}
}
return deselected;
}
Aggregations