Class VirtualChannelSelectorImpl
- java.lang.Object
-
- com.biglybt.core.networkmanager.impl.tcp.VirtualChannelSelectorImpl
-
public class VirtualChannelSelectorImpl extends java.lang.Object
Provides a simplified and safe (selectable-channel) socket single-op selector.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
VirtualChannelSelectorImpl.RegistrationData
private static class
VirtualChannelSelectorImpl.SelectorTimeoutException
-
Field Summary
Fields Modifier and Type Field Description private int
consec_select_fails
private long
consec_select_fails_start
private boolean
destroyed
(package private) static AESemaphore
get_selector_allowed
private int
INTEREST_OP
private long
last_reopen_attempt
private long
last_select_debug
private long
last_write_select_debug
private boolean
logged_broken_select
private static LogIDs
LOGID
private static boolean
MAYBE_BROKEN_SELECT
private int
next_select_loop_pos
protected VirtualChannelSelector
parent
private boolean
pause_after_select
private java.util.HashMap<java.nio.channels.spi.AbstractSelectableChannel,java.lang.Boolean>
paused_states
private boolean
randomise_keys
private java.util.Map<java.nio.channels.spi.AbstractSelectableChannel,java.lang.Object>
register_cancel_list
private AEMonitor
register_cancel_list_mon
private boolean
select_is_broken
private int
select_looks_broken_count
protected java.nio.channels.Selector
selector
private SelectorGuard
selector_guard
private static int
SELECTOR_TIMEOUT
private static int
WRITE_SELECTOR_DEBUG_CHECK_PERIOD
private static int
WRITE_SELECTOR_DEBUG_MAX_TIME
-
Constructor Summary
Constructors Constructor Description VirtualChannelSelectorImpl(VirtualChannelSelector _parent, int _interest_op, boolean _pause_after_select, boolean _randomise_keys)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel(java.nio.channels.spi.AbstractSelectableChannel channel)
protected void
closeExistingSelector()
void
destroy()
Note that you have to ensure that a select operation is performed on the normal select loop *after* destroying the selector to actually cause the destroy to occurprivate static java.nio.channels.Selector
getSelector()
boolean
isPaused(java.nio.channels.spi.AbstractSelectableChannel channel)
boolean
isRegistered(java.nio.channels.spi.AbstractSelectableChannel channel)
protected java.nio.channels.Selector
openNewSelector()
void
pauseSelects(java.nio.channels.spi.AbstractSelectableChannel channel)
void
register(java.nio.channels.spi.AbstractSelectableChannel channel, VirtualChannelSelector.VirtualAbstractSelectorListener listener, java.lang.Object attachment)
void
resumeSelects(java.nio.channels.spi.AbstractSelectableChannel channel)
int
select(long timeout)
void
setRandomiseKeys(boolean r)
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
MAYBE_BROKEN_SELECT
private static final boolean MAYBE_BROKEN_SELECT
-
SELECTOR_TIMEOUT
private static final int SELECTOR_TIMEOUT
- See Also:
- Constant Field Values
-
get_selector_allowed
static final AESemaphore get_selector_allowed
-
select_is_broken
private boolean select_is_broken
-
select_looks_broken_count
private int select_looks_broken_count
-
logged_broken_select
private boolean logged_broken_select
-
selector
protected java.nio.channels.Selector selector
-
selector_guard
private final SelectorGuard selector_guard
-
consec_select_fails
private int consec_select_fails
-
consec_select_fails_start
private long consec_select_fails_start
-
register_cancel_list
private final java.util.Map<java.nio.channels.spi.AbstractSelectableChannel,java.lang.Object> register_cancel_list
-
register_cancel_list_mon
private final AEMonitor register_cancel_list_mon
-
paused_states
private final java.util.HashMap<java.nio.channels.spi.AbstractSelectableChannel,java.lang.Boolean> paused_states
-
INTEREST_OP
private final int INTEREST_OP
-
pause_after_select
private final boolean pause_after_select
-
parent
protected final VirtualChannelSelector parent
-
destroyed
private volatile boolean destroyed
-
randomise_keys
private boolean randomise_keys
-
next_select_loop_pos
private int next_select_loop_pos
-
WRITE_SELECTOR_DEBUG_CHECK_PERIOD
private static final int WRITE_SELECTOR_DEBUG_CHECK_PERIOD
- See Also:
- Constant Field Values
-
WRITE_SELECTOR_DEBUG_MAX_TIME
private static final int WRITE_SELECTOR_DEBUG_MAX_TIME
- See Also:
- Constant Field Values
-
last_write_select_debug
private long last_write_select_debug
-
last_select_debug
private long last_select_debug
-
last_reopen_attempt
private long last_reopen_attempt
-
-
Constructor Detail
-
VirtualChannelSelectorImpl
public VirtualChannelSelectorImpl(VirtualChannelSelector _parent, int _interest_op, boolean _pause_after_select, boolean _randomise_keys)
-
-
Method Detail
-
getSelector
private static java.nio.channels.Selector getSelector() throws java.io.IOException
- Throws:
java.io.IOException
-
openNewSelector
protected java.nio.channels.Selector openNewSelector()
-
setRandomiseKeys
public void setRandomiseKeys(boolean r)
-
isPaused
public boolean isPaused(java.nio.channels.spi.AbstractSelectableChannel channel)
-
pauseSelects
public void pauseSelects(java.nio.channels.spi.AbstractSelectableChannel channel)
-
resumeSelects
public void resumeSelects(java.nio.channels.spi.AbstractSelectableChannel channel)
-
isRegistered
public boolean isRegistered(java.nio.channels.spi.AbstractSelectableChannel channel)
-
cancel
public void cancel(java.nio.channels.spi.AbstractSelectableChannel channel)
-
register
public void register(java.nio.channels.spi.AbstractSelectableChannel channel, VirtualChannelSelector.VirtualAbstractSelectorListener listener, java.lang.Object attachment)
-
select
public int select(long timeout)
-
destroy
public void destroy()
Note that you have to ensure that a select operation is performed on the normal select loop *after* destroying the selector to actually cause the destroy to occur
-
closeExistingSelector
protected void closeExistingSelector()
-
-