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

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


  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     }




  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      * Callback method for implementations that need special handling when fd is
  81      * removed (currently only needed in the AIX-Port - see AixPollPort.java).
  82      */
  83     protected void preUnregister(int fd) {
  84         // Do nothing by default.
  85     }
  86 
  87     /**
  88      * Unregister channel identified by its file descriptor
  89      */
  90     final void unregister(int fd) {
  91         boolean checkForShutdown = false;
  92 
  93         preUnregister(fd);
  94 
  95         fdToChannelLock.writeLock().lock();
  96         try {
  97             fdToChannel.remove(Integer.valueOf(fd));
  98 
  99             // last key to be removed so check if group is shutdown
 100             if (fdToChannel.isEmpty())
 101                 checkForShutdown = true;
 102 
 103         } finally {
 104             fdToChannelLock.writeLock().unlock();
 105         }
 106 
 107         // continue shutdown
 108         if (checkForShutdown && isShutdown()) {
 109             try {
 110                 shutdownNow();
 111             } catch (IOException ignore) { }
 112         }
 113     }