當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractSelectableChannel.isOpen方法代碼示例

本文整理匯總了Java中java.nio.channels.spi.AbstractSelectableChannel.isOpen方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractSelectableChannel.isOpen方法的具體用法?Java AbstractSelectableChannel.isOpen怎麽用?Java AbstractSelectableChannel.isOpen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.channels.spi.AbstractSelectableChannel的用法示例。


在下文中一共展示了AbstractSelectableChannel.isOpen方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: pauseSelects

import java.nio.channels.spi.AbstractSelectableChannel; //導入方法依賴的package包/類
public void pauseSelects( AbstractSelectableChannel channel ) {

      //System.out.println( "pauseSelects: " + channel + " - " + Debug.getCompressedStackTrace() );

      if( channel == null ) {
        return;
      }

      SelectionKey key = channel.keyFor( selector );

      if( key != null && key.isValid() ) {
        key.interestOps( key.interestOps() & ~INTEREST_OP );
      }
      else {  //channel not (yet?) registered
        if( channel.isOpen() ) {  //only bother if channel has not already been closed
          try{  register_cancel_list_mon.enter();

            paused_states.put( channel, Boolean.TRUE);  //ensure the op is paused upon reg select-time reg

          }
          finally{  register_cancel_list_mon.exit();  }
        }
      }
    }
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:25,代碼來源:VirtualChannelSelectorImpl.java

示例2: pauseSelects

import java.nio.channels.spi.AbstractSelectableChannel; //導入方法依賴的package包/類
public void pauseSelects( AbstractSelectableChannel channel ) {
  
  //System.out.println( "pauseSelects: " + channel + " - " + Debug.getCompressedStackTrace() );
  
  if( channel == null ) {
    return;
  }
  
  SelectionKey key = channel.keyFor( selector );
  
  if( key != null && key.isValid() ) {
    key.interestOps( key.interestOps() & ~INTEREST_OP );
  }
  else {  //channel not (yet?) registered
    if( channel.isOpen() ) {  //only bother if channel has not already been closed
      try{  register_cancel_list_mon.enter();
      
        paused_states.put( channel, new Boolean( true ) );  //ensure the op is paused upon reg select-time reg

      }
      finally{  register_cancel_list_mon.exit();  }
    }
  }
}
 
開發者ID:thangbn,項目名稱:Direct-File-Downloader,代碼行數:25,代碼來源:VirtualChannelSelectorImpl.java

示例3: close

import java.nio.channels.spi.AbstractSelectableChannel; //導入方法依賴的package包/類
public static void close(AbstractSelectableChannel channel) {
    if (channel != null && channel.isOpen()) {
        try {
            channel.close();
        } catch (IOException e) {
            LOGGER.error("Fail to close channel", e);
        }
    }
}
 
開發者ID:NetCrusherOrg,項目名稱:netcrusher-java,代碼行數:10,代碼來源:NioUtils.java

示例4: closeSocketChannel

import java.nio.channels.spi.AbstractSelectableChannel; //導入方法依賴的package包/類
private void closeSocketChannel( AbstractSelectableChannel channel , Selector selector )
{
    try
    {
        SelectionKey sk = channel.keyFor(selector);
        if (sk != null && sk.isValid())
            sk.cancel();
        if (channel.isOpen())
            channel.close();
    }
    catch (Exception e)
    {
        log.error("Could not close channel : "+e.toString());
    }
}
 
開發者ID:timewalker74,項目名稱:ffmq,代碼行數:16,代碼來源:NIOTcpMultiplexer.java


注:本文中的java.nio.channels.spi.AbstractSelectableChannel.isOpen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。