src/solaris/classes/sun/nio/ch/Port.java

Print this page
rev 8725 : 8024854: Basic changes and files to build the class library on AIX
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan


  59 
  60 
  61     Port(AsynchronousChannelProvider provider, ThreadPool pool) {
  62         super(provider, pool);
  63     }
  64 
  65     /**
  66      * Register channel identified by its file descriptor
  67      */
  68     final void register(int fd, PollableChannel ch) {
  69         fdToChannelLock.writeLock().lock();
  70         try {
  71             if (isShutdown())
  72                 throw new ShutdownChannelGroupException();
  73             fdToChannel.put(Integer.valueOf(fd), ch);
  74         } finally {
  75             fdToChannelLock.writeLock().unlock();
  76         }
  77     }
  78 






  79     /**
  80      * Unregister channel identified by its file descriptor
  81      */
  82     final void unregister(int fd) {
  83         boolean checkForShutdown = false;


  84 
  85         fdToChannelLock.writeLock().lock();
  86         try {
  87             fdToChannel.remove(Integer.valueOf(fd));
  88 
  89             // last key to be removed so check if group is shutdown
  90             if (fdToChannel.isEmpty())
  91                 checkForShutdown = true;
  92 
  93         } finally {
  94             fdToChannelLock.writeLock().unlock();
  95         }
  96 
  97         // continue shutdown
  98         if (checkForShutdown && isShutdown()) {
  99             try {
 100                 shutdownNow();
 101             } catch (IOException ignore) { }
 102         }
 103     }




  59 
  60 
  61     Port(AsynchronousChannelProvider provider, ThreadPool pool) {
  62         super(provider, pool);
  63     }
  64 
  65     /**
  66      * Register channel identified by its file descriptor
  67      */
  68     final void register(int fd, PollableChannel ch) {
  69         fdToChannelLock.writeLock().lock();
  70         try {
  71             if (isShutdown())
  72                 throw new ShutdownChannelGroupException();
  73             fdToChannel.put(Integer.valueOf(fd), ch);
  74         } finally {
  75             fdToChannelLock.writeLock().unlock();
  76         }
  77     }
  78 
  79     // Callback method for implementations that need special handling when fd is
  80     // removed (currently only needed in the AIX-Port - see AixPollPort.java)
  81     void unregisterImpl(int fd) {
  82         // Do nothing by default.
  83     }
  84 
  85     /**
  86      * Unregister channel identified by its file descriptor
  87      */
  88     final void unregister(int fd) {
  89         boolean checkForShutdown = false;
  90 
  91         unregisterImpl(fd);
  92 
  93         fdToChannelLock.writeLock().lock();
  94         try {
  95             fdToChannel.remove(Integer.valueOf(fd));
  96 
  97             // last key to be removed so check if group is shutdown
  98             if (fdToChannel.isEmpty())
  99                 checkForShutdown = true;
 100 
 101         } finally {
 102             fdToChannelLock.writeLock().unlock();
 103         }
 104 
 105         // continue shutdown
 106         if (checkForShutdown && isShutdown()) {
 107             try {
 108                 shutdownNow();
 109             } catch (IOException ignore) { }
 110         }
 111     }