当前位置: 首页>>代码示例>>Java>>正文


Java AbstractSelectableChannel类代码示例

本文整理汇总了Java中java.nio.channels.spi.AbstractSelectableChannel的典型用法代码示例。如果您正苦于以下问题:Java AbstractSelectableChannel类的具体用法?Java AbstractSelectableChannel怎么用?Java AbstractSelectableChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractSelectableChannel类属于java.nio.channels.spi包,在下文中一共展示了AbstractSelectableChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pauseSelects

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
/**
 * Pause selection operations for the given channel
 * @param channel to pause
 */
public void pauseSelects( AbstractSelectableChannel channel ) {
  if( SAFE_SELECTOR_MODE_ENABLED ) {
    try{  selectors_mon.enter();
    	//System.out.println( "pause - " + channel.hashCode() + " - " + Debug.getCompressedStackTrace());
    for( Map.Entry<VirtualChannelSelectorImpl, ArrayList<AbstractSelectableChannel>> entry: selectors.entrySet()) {

        VirtualChannelSelectorImpl 			sel 		= entry.getKey();
        ArrayList<AbstractSelectableChannel> 	channels 	= entry.getValue();

        if( channels.contains( channel ) ) {
          sel.pauseSelects( channel );
          return;
        }
      }

      Debug.out( "pauseSelects():: channel not found!" );
    }
    finally{ selectors_mon.exit();  }
  }
  else {
    selector_impl.pauseSelects( channel );
  }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:28,代码来源:VirtualChannelSelector.java

示例2: resumeSelects

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
/**
 * Resume selection operations for the given channel
 * @param channel to resume
 */
public void resumeSelects( AbstractSelectableChannel channel ) {
  if( SAFE_SELECTOR_MODE_ENABLED ) {
    try{  selectors_mon.enter();
    	//System.out.println( "resume - " + channel.hashCode() + " - " + Debug.getCompressedStackTrace());
    for( Map.Entry<VirtualChannelSelectorImpl, ArrayList<AbstractSelectableChannel>> entry: selectors.entrySet()) {

        VirtualChannelSelectorImpl 			sel 		= entry.getKey();
        ArrayList<AbstractSelectableChannel> 	channels 	= entry.getValue();

        if( channels.contains( channel ) ) {
          sel.resumeSelects( channel );
          return;
        }
      }

      Debug.out( "resumeSelects():: channel not found!" );
    }
    finally{ selectors_mon.exit();  }
  }
  else {
    selector_impl.resumeSelects( channel );
  }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:28,代码来源:VirtualChannelSelector.java

示例3: cancel

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
/**
 * Cancel the selection operations for the given channel.
 * @param channel channel originally registered
 */
public void cancel( AbstractSelectableChannel channel ) {
  if( SAFE_SELECTOR_MODE_ENABLED ) {
    try{  selectors_mon.enter();
    	//System.out.println( "cancel - " + channel.hashCode()  + " - " + Debug.getCompressedStackTrace());
    for( Map.Entry<VirtualChannelSelectorImpl, ArrayList<AbstractSelectableChannel>> entry: selectors.entrySet()) {

        VirtualChannelSelectorImpl 			sel 		= entry.getKey();
        ArrayList<AbstractSelectableChannel> 	channels 	= entry.getValue();

        if( channels.remove( channel ) ) {
          sel.cancel( channel );
          return;
        }
      }
    }
    finally{ selectors_mon.exit();  }
  }
  else {
    if( selector_impl != null )  selector_impl.cancel( channel );
  }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:26,代码来源:VirtualChannelSelector.java

示例4: selectFailure

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
public void
 selectFailure(
VirtualAbstractSelectorListener		listener,
AbstractSelectableChannel 			sc,
Object 								attachment,
Throwable							msg)
 {
  if ( op == OP_ACCEPT ){

	  ((VirtualAcceptSelectorListener)listener).selectFailure( VirtualChannelSelector.this, (ServerSocketChannel)sc, attachment, msg );
  }else{

	  ((VirtualSelectorListener)listener).selectFailure( VirtualChannelSelector.this, (SocketChannel)sc, attachment, msg );

  }
 }
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:17,代码来源:VirtualChannelSelector.java

示例5: 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

示例6: pauseSelects

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
/**
 * Pause selection operations for the given channel
 * @param channel to pause
 */
public void pauseSelects( AbstractSelectableChannel channel ) {
  if( SAFE_SELECTOR_MODE_ENABLED ) {
    try{  selectors_mon.enter();
    	//System.out.println( "pause - " + channel.hashCode() + " - " + Debug.getCompressedStackTrace());
    for( Map.Entry<VirtualChannelSelectorImpl, ArrayList<AbstractSelectableChannel>> entry: selectors.entrySet()) {
        
        VirtualChannelSelectorImpl 			sel 		= entry.getKey();
        ArrayList<AbstractSelectableChannel> 	channels 	= entry.getValue();
        
        if( channels.contains( channel ) ) {
          sel.pauseSelects( channel );
          return;
        }
      }
      
      Debug.out( "pauseSelects():: channel not found!" );
    }
    finally{ selectors_mon.exit();  }
  }
  else {
    selector_impl.pauseSelects( channel );
  }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:28,代码来源:VirtualChannelSelector.java

示例7: resumeSelects

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
/**
 * Resume selection operations for the given channel
 * @param channel to resume
 */
public void resumeSelects( AbstractSelectableChannel channel ) {
  if( SAFE_SELECTOR_MODE_ENABLED ) {
    try{  selectors_mon.enter();
    	//System.out.println( "resume - " + channel.hashCode() + " - " + Debug.getCompressedStackTrace());
    for( Map.Entry<VirtualChannelSelectorImpl, ArrayList<AbstractSelectableChannel>> entry: selectors.entrySet()) {
        
        VirtualChannelSelectorImpl 			sel 		= entry.getKey();
        ArrayList<AbstractSelectableChannel> 	channels 	= entry.getValue();
        
        if( channels.contains( channel ) ) {
          sel.resumeSelects( channel );
          return;
        }
      }
      
      Debug.out( "resumeSelects():: channel not found!" );
    }
    finally{ selectors_mon.exit();  }
  }
  else {
    selector_impl.resumeSelects( channel );
  }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:28,代码来源:VirtualChannelSelector.java

示例8: cancel

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
/**
 * Cancel the selection operations for the given channel.
 * @param channel channel originally registered
 */
public void cancel( AbstractSelectableChannel channel ) {
  if( SAFE_SELECTOR_MODE_ENABLED ) {
    try{  selectors_mon.enter();
    	//System.out.println( "cancel - " + channel.hashCode()  + " - " + Debug.getCompressedStackTrace());
    for( Map.Entry<VirtualChannelSelectorImpl, ArrayList<AbstractSelectableChannel>> entry: selectors.entrySet()) {
        
        VirtualChannelSelectorImpl 			sel 		= entry.getKey();
        ArrayList<AbstractSelectableChannel> 	channels 	= entry.getValue();
        
        if( channels.remove( channel ) ) {
          sel.cancel( channel );
          return;
        }
      }
    }
    finally{ selectors_mon.exit();  }
  }
  else {
    if( selector_impl != null )  selector_impl.cancel( channel );
  }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:26,代码来源:VirtualChannelSelector.java

示例9: selectFailure

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
public void
 selectFailure(
VirtualAbstractSelectorListener		listener,
AbstractSelectableChannel 			sc, 
Object 								attachment, 
Throwable							msg)
 {
  if ( op == OP_ACCEPT ){
	  
	  ((VirtualAcceptSelectorListener)listener).selectFailure( VirtualChannelSelector.this, (ServerSocketChannel)sc, attachment, msg );
  }else{
	
	  ((VirtualSelectorListener)listener).selectFailure( VirtualChannelSelector.this, (SocketChannel)sc, attachment, msg );

  }
 }
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:17,代码来源:VirtualChannelSelector.java

示例10: 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

示例11: register

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
public void register(AbstractSelectableChannel channel, GroupPurpose purpose, Object attachment) {
    int ops = 0;

    switch (purpose) {
        case ACCEPT:
        default:
            ops = SelectionKey.OP_ACCEPT;
            break;

        case IO:
            ops = SelectionKey.OP_READ | SelectionKey.OP_WRITE;
            break;
    }

    try {
        if (attachment != null) {
            channel.register(this.selector, ops, attachment);
        } else {
            channel.register(this.selector, ops);
        }
    } catch (Exception e) {
        log.warn("Error during selector registration", e);
    }
}
 
开发者ID:LeonHartley,项目名称:Coerce,代码行数:25,代码来源:NioEventExecutor.java

示例12: register

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
protected final SelectionKey register (AbstractSelectableChannel ch, int ops,
                                       Object att)
{
  SelectionKeyImpl result;

  if (ch instanceof SocketChannelImpl)
    result = new SocketChannelSelectionKey (ch, this);
  else if (ch instanceof DatagramChannelImpl)
    result = new DatagramChannelSelectionKey (ch, this);
  else if (ch instanceof ServerSocketChannelImpl)
    result = new ServerSocketChannelSelectionKey (ch, this);
  else if (ch instanceof gnu.java.nio.SocketChannelImpl)
    result = new gnu.java.nio.SocketChannelSelectionKeyImpl((gnu.java.nio.SocketChannelImpl)ch, this);
  else
    throw new InternalError ("No known channel type");

  synchronized (keys)
    {
      keys.add (result);

      result.interestOps (ops);
      result.attach (att);
    }

  return result;
}
 
开发者ID:vilie,项目名称:javify,代码行数:27,代码来源:SelectorImpl.java

示例13: register

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
protected final SelectionKey register (AbstractSelectableChannel ch, int ops,
                                        Object att)
 {
   SelectionKeyImpl result;
   
   if (ch instanceof SocketChannelImpl)
     result = new SocketChannelSelectionKey (ch, this);
   else if (ch instanceof DatagramChannelImpl)
     result = new DatagramChannelSelectionKey (ch, this);
   else if (ch instanceof ServerSocketChannelImpl)
     result = new ServerSocketChannelSelectionKey (ch, this);
   else if (ch instanceof gnu.java.nio.SocketChannelImpl)
     result = new gnu.java.nio.SocketChannelSelectionKeyImpl((gnu.java.nio.SocketChannelImpl)ch, this);
   else
     throw new InternalError ("No known channel type");

   synchronized (keys)
     {
       keys.add (result);

result.interestOps (ops);
result.attach (att);
     }

   return result;
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:27,代码来源:SelectorImpl.java

示例14: test_register_LAbstractSelectableChannelIObject

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
/**
 * @tests AbstractSelector#register(AbstractSelectableChannel,int,Object)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies register method from SelectableChannel class.",
    method = "register",
    args = {AbstractSelectableChannel.class, int.class, java.lang.Object.class}
)
public void test_register_LAbstractSelectableChannelIObject()
        throws Exception {
    Selector acceptSelector = new MockSelectorProvider().openSelector();
    ServerSocketChannel ssc = ServerSocketChannel.open();
    ssc.configureBlocking(false);

    assertFalse(ssc.isRegistered());
    ssc.register(acceptSelector, SelectionKey.OP_ACCEPT);
    assertTrue(ssc.isRegistered());
    assertTrue(((MockAbstractSelector)acceptSelector).isRegisterCalled);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:AbstractSelectorTest.java

示例15: register

import java.nio.channels.spi.AbstractSelectableChannel; //导入依赖的package包/类
protected SelectionKey register(AbstractSelectableChannel channel,
        int operations, Object attachment) {
    if (!provider().equals(channel.provider())) {
        throw new IllegalSelectorException();
    }
    synchronized (this) {
        synchronized (keysSet) {

            // System.out.println("Registering channel");
            // create the key
            SelectionKey sk = new EpollSelectionKeyImpl(channel,
                    operations, attachment, this);

            int index = addKey(sk);
            ((EpollSelectionKeyImpl) sk).setIndex(index);

            // System.out.println(" channel registered with index = " +
            // index);
            return sk;
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:EpollSelectorImpl.java


注:本文中的java.nio.channels.spi.AbstractSelectableChannel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。