diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-25 10:17:00 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-25 10:17:00 +0000 |
commit | 7113237bf329e1245f096787093aed051ea2dd23 (patch) | |
tree | f64cac1e9b4351a90bd0d14b21a18d7bf91b962b /libjava/gnu/java/nio/SelectorImpl.java | |
parent | bd00731b7faa408b2b2422b829a24994b52ee22d (diff) | |
download | ppe42-gcc-7113237bf329e1245f096787093aed051ea2dd23.tar.gz ppe42-gcc-7113237bf329e1245f096787093aed051ea2dd23.zip |
2003-09-25 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/DatagramChannelImpl.java
(DatagramChannelImpl): Made class final.
(blocking): Made private.
(socket): Made it a NIODatagramSocket and private.
(DatagramChannelImpl): create NIODatagramSocket instead of
DatagramSocket.
(implConfigureBlocking): Set socket timeout.
(connect): Check that channel is not closed.
(write): Implemented.
(write): Rewritten.
(read): Implemented.
(read): Rewritten.
(receive): Implemented.
(send): Implemented.
* gnu/java/nio/SelectionKeyImpl.java
(readyOps): Made private.
(interestOps): Made private.
(impl): Made private.
(ch): Made private.
(readyOps): Check if selection key is valid.
(interestOps): Likewise.
* gnu/java/nio/SelectorImpl.java
(closed): Removed.
(keys): Made private.
(selected): Made private.
(finalize): New method.
(implCloseSelector): Rewritten.
(keys): Return unmodifiable Set.
(deregisterCancelledKeys): Fixed typo in method name.
* gnu/java/nio/SocketChannelImpl.java
(SocketChannelImpl): Made class final.
(socket): Made it a NIOSocket and private.
(blocking): Made private.
(connected): Made private.
(connectionPending): New member variable.
(SocketChannelImpl): New implementation.
(finalizer): Use isConnected().
(connect): Rewritten.
(finishConnect): Throws IOException, implemented.
(isConnectionPending): Return connectionPending.
(read): Rewritten.
(write): Rewritten.
* gnu/java/nio/NIOConstants.java: New file.
* Makefile.am (ordinary_java_source_files):
Added gnu/java/nio/NIOConstants.java.
* Makefile.in: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/java/nio/SelectorImpl.java')
-rw-r--r-- | libjava/gnu/java/nio/SelectorImpl.java | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/libjava/gnu/java/nio/SelectorImpl.java b/libjava/gnu/java/nio/SelectorImpl.java index 9f714cc70c5..a906641ac75 100644 --- a/libjava/gnu/java/nio/SelectorImpl.java +++ b/libjava/gnu/java/nio/SelectorImpl.java @@ -1,5 +1,5 @@ /* SelectorImpl.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,6 +37,7 @@ exception statement from your version. */ package gnu.java.nio; +import java.io.IOException; import java.nio.channels.ClosedSelectorException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; @@ -44,14 +45,15 @@ import java.nio.channels.Selector; import java.nio.channels.spi.AbstractSelectableChannel; import java.nio.channels.spi.AbstractSelector; import java.nio.channels.spi.SelectorProvider; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class SelectorImpl extends AbstractSelector { - boolean closed = false; - Set keys, selected, canceled; + private Set keys; + private Set selected; public SelectorImpl (SelectorProvider provider) { @@ -59,12 +61,23 @@ public class SelectorImpl extends AbstractSelector keys = new HashSet (); selected = new HashSet (); - canceled = new HashSet (); } - public Set keys () + protected void finalize() throws Throwable { - return keys; + close(); + } + + protected final void implCloseSelector() + throws IOException + { + // FIXME: We surely need to do more here. + wakeup(); + } + + public final Set keys() + { + return Collections.unmodifiableSet (keys); } public int selectNow () @@ -120,10 +133,8 @@ public class SelectorImpl extends AbstractSelector public int select (long timeout) { - if (closed) - { - throw new ClosedSelectorException (); - } + if (!isOpen()) + throw new ClosedSelectorException (); if (keys == null) { @@ -132,7 +143,7 @@ public class SelectorImpl extends AbstractSelector int ret = 0; - deregisterCanceledKeys (); + deregisterCancelledKeys(); // Set only keys with the needed interest ops into the arrays. int[] read = getFDsAsArray (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT); @@ -202,7 +213,7 @@ public class SelectorImpl extends AbstractSelector key.readyOps (key.interestOps () & ops); } - deregisterCanceledKeys (); + deregisterCancelledKeys(); return ret; } @@ -226,14 +237,9 @@ public class SelectorImpl extends AbstractSelector selected.add (k); } - protected void implCloseSelector () - { - closed = true; - } - - private void deregisterCanceledKeys () + private void deregisterCancelledKeys () { - Iterator it = canceled.iterator (); + Iterator it = cancelledKeys().iterator(); while (it.hasNext ()) { |