This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: gnu.java.nio.SelectorImpl


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I commited the attached patch to trunk to make the selector stuff a 
little bit cleaner.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/cwuvWSOgCCdjSDsRAtpdAJ91H3sbvwjwEWY6eZaQs7dyvMdL5gCglDhW
pIAiTEXDYc9CPevJsmEC18U=
=BTC4
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2181
diff -u -b -B -r1.2181 ChangeLog
--- ChangeLog	25 Sep 2003 14:37:57 -0000	1.2181
+++ ChangeLog	25 Sep 2003 15:17:30 -0000
@@ -1,3 +1,20 @@
+2003-09-25  Michael Koch  <konqueror@gmx.de>
+
+	* gnu/java/nio/SelectorImpl.java
+	(selectNow): Made final, throws IOException.
+	(select): Likewise.
+	(getFDsAsArray): Made final.
+	(selectedKeys): Likewise.
+	(wakeup): Likewise.
+	(deregisterCancelledKeys): Likewise.
+	(register): Likewise.
+	(ass): Removed.
+	(add_selected): Removed.
+	* gnu/java/nio/natSelectorImpl.cc:
+	No need to include bstring.h or gcj/cni.h.
+	(helper_put_filedescriptors): Rewritten.
+	(helper_get_filedescriptors): Rewritten.
+
 2003-09-25  Sascha Brawer  <brawer@dandelis.ch>
 
 	* java/awt/font/FontRenderContext.java (getTransform): Return
Index: gnu/java/nio/SelectorImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/SelectorImpl.java,v
retrieving revision 1.6
diff -u -b -B -r1.6 SelectorImpl.java
--- gnu/java/nio/SelectorImpl.java	25 Sep 2003 10:16:59 -0000	1.6
+++ gnu/java/nio/SelectorImpl.java	25 Sep 2003 15:17:30 -0000
@@ -80,12 +80,14 @@
     return Collections.unmodifiableSet (keys);
   }
     
-  public int selectNow ()
+  public final int selectNow()
+    throws IOException
   {
     return select (1);
   }
 
-  public int select ()
+  public final int select()
+    throws IOException
   {
     return select (-1);
   }
@@ -94,7 +96,7 @@
   private static native int java_do_select (int[] read, int[] write,
                                             int[] except, long timeout);
 
-  private int[] getFDsAsArray (int ops)
+  private final int[] getFDsAsArray (int ops)
   {
     int[] result;
     int counter = 0;
@@ -206,7 +208,7 @@
         // If key is not yet selected add it.
         if (!selected.contains (key))
           {
-            add_selected (key);
+            selected.add (key);
           }
 
         // Set new ready ops
@@ -217,27 +219,17 @@
     return ret;
   }
     
-  public Set selectedKeys ()
+  public final Set selectedKeys()
   {
     return selected;
   }
 
-  public Selector wakeup ()
+  public final Selector wakeup()
   {
     return null;
   }
 
-  public void add (SelectionKeyImpl k)
-  {
-    keys.add (k);
-  }
-
-  void add_selected (SelectionKeyImpl k)
-  {
-    selected.add (k);
-  }
-
-  private void deregisterCancelledKeys ()
+  private final void deregisterCancelledKeys()
   {
     Iterator it = cancelledKeys().iterator();
 
@@ -253,7 +245,7 @@
     return register ((AbstractSelectableChannel) ch, ops, att);
   }
 
-  protected SelectionKey register (AbstractSelectableChannel ch, int ops,
+  protected final SelectionKey register (AbstractSelectableChannel ch, int ops,
                                    Object att)
   {
     SelectionKeyImpl result;
@@ -278,7 +270,7 @@
         throw new InternalError ("No known channel type");
       }
 
-    add (result);
+    keys.add (result);
     result.interestOps (ops);
     result.attach (att);
     return result;
Index: gnu/java/nio/natSelectorImpl.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/natSelectorImpl.cc,v
retrieving revision 1.1
diff -u -b -B -r1.1 natSelectorImpl.cc
--- gnu/java/nio/natSelectorImpl.cc	29 Nov 2002 07:56:58 -0000	1.1
+++ gnu/java/nio/natSelectorImpl.cc	25 Sep 2003 15:17:30 -0000
@@ -1,6 +1,6 @@
 // natSelectorImpl.cc
 
-/* Copyright (C) 2002  Free Software Foundation
+/* Copyright (C) 2002, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -14,66 +14,31 @@
 #include <errno.h>
 #include <string.h>
 
-#if HAVE_BSTRING_H
-// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2 
-#include <bstring.h>
-#endif
-
-//#include <gcj/cni.h>
 #include <gnu/java/nio/SelectorImpl.h>
 #include <java/io/IOException.h>
 
 void
-helper_put_filedescriptors (jintArray java_fd_array, fd_set& fds, int& max_fd)
+helper_put_filedescriptors (jintArray fdArray, fd_set& fds, int& max_fd)
 {
-  int counter;
-  jint* java_fds;
-
-  java_fds = elements (java_fd_array);
+  jint* tmpFDArray = elements (fdArray);
 
-  for (counter = 0; counter < JvGetArrayLength (java_fd_array); counter++)
+  for (int index = 0; index < JvGetArrayLength (fdArray); index++)
     {
-      FD_SET (java_fds [counter], &fds);
+      FD_SET (tmpFDArray [index], &fds);
 
-      if (java_fds [counter] > max_fd)
-        {
-          max_fd = java_fds [counter];
-        }
+      if (tmpFDArray [index] > max_fd)
+        max_fd = tmpFDArray [index];
     }
 }
 
 void
-helper_get_filedescriptors (jintArray& java_fd_array, fd_set fds)
+helper_get_filedescriptors (jintArray& fdArray, fd_set fds)
 {
-  int counter;
-  int counter_fds;
-  jint* java_fds;
-  jintArray new_array_fds;
-  jint* new_data_fds;
-
-  counter_fds = 0;
-  java_fds = elements (java_fd_array);
-
-  for (counter = 0; counter < JvGetArrayLength (java_fd_array); counter++)
-    {
-      if (FD_ISSET (java_fds[counter], &fds))
-        {
-          counter_fds++;
-        }
-    }
-
-  new_array_fds = JvNewIntArray (counter_fds);
-  new_data_fds = elements (new_array_fds);
-
-  for (counter = 0; counter < JvGetArrayLength (java_fd_array); counter++)
-    {
-      if (FD_ISSET (java_fds[counter], &fds))
-        {
-          new_data_fds[counter] = java_fds[counter];
-        }      
-    }
+  jint* tmpFDArray = elements (fdArray);
 
-  java_fd_array = new_array_fds;
+  for (int index = 0; index < JvGetArrayLength (fdArray); index++)
+    if (!FD_ISSET (tmpFDArray [index], &fds))
+      tmpFDArray [index] = 0;
 }
 
 jint

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]