There's a method for that.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6159 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -8,6 +8,8 @@ import java.io.IOException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import static com.threerings.presents.Log.log;
|
||||
|
||||
/**
|
||||
@@ -38,23 +40,7 @@ public class SelectorIterable
|
||||
|
||||
public Iterator<SelectionKey> iterator ()
|
||||
{
|
||||
final Iterator<SelectionKey> it = select().iterator();
|
||||
return new Iterator<SelectionKey>() {
|
||||
public boolean hasNext () {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
public SelectionKey next () {
|
||||
SelectionKey key = it.next();
|
||||
it.remove();
|
||||
return key;
|
||||
}
|
||||
|
||||
public void remove () {
|
||||
throw new UnsupportedOperationException(
|
||||
"Removing from the selected keys is done automatically on next()");
|
||||
}
|
||||
};
|
||||
return Iterators.consumingIterator(select().iterator());
|
||||
}
|
||||
|
||||
protected Set<SelectionKey> select ()
|
||||
|
||||
Reference in New Issue
Block a user