/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, false); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, false); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, false); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor, boolean isInAppendMode) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, isInAppendMode); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor, boolean isInAppendMode) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, isInAppendMode); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, false); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor, boolean isInAppendMode) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, isInAppendMode); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor * @param fileDescriptor The java.io.FileDescriptor object for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes, FileDescriptor fileDescriptor, boolean isInAppendMode) { this(channel, getNewFileno(), originalModes, fileDescriptor, new AtomicInteger(1), true, isInAppendMode); }
@Deprecated public static int getNewFileno() { return ChannelDescriptor.getNewFileno(); }
@Deprecated public static int getNewFileno() { return ChannelDescriptor.getNewFileno(); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes) { this(channel, getNewFileno(), originalModes, FilenoUtil.getDescriptorFromChannel(channel), new AtomicInteger(1), true, false); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes) { this(channel, getNewFileno(), originalModes, getDescriptorFromChannel(channel), new AtomicInteger(1), true, false); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes) { this(channel, getNewFileno(), originalModes, FilenoUtil.getDescriptorFromChannel(channel), new AtomicInteger(1), true, false); }
/** * Construct a new ChannelDescriptor with the given channel, file number, mode flags, * and file descriptor object. The channel will be kept open until all ChannelDescriptor * references to it have been closed. * * @param channel The channel for the new descriptor * @param originalModes The mode flags for the new descriptor */ public ChannelDescriptor(Channel channel, ModeFlags originalModes) { this(channel, getNewFileno(), originalModes, getDescriptorFromChannel(channel), new AtomicInteger(1), true, false); }
/** * Mimics the POSIX dup(2) function, returning a new descriptor that references * the same open channel. * * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup() { synchronized (refCounter) { refCounter.incrementAndGet(); int newFileno = getNewFileno(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", newFileno, refCounter.get()); return new ChannelDescriptor(channel, newFileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
/** * Mimics the POSIX dup(2) function, returning a new descriptor that references * the same open channel. * * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup() { synchronized (refCounter) { refCounter.incrementAndGet(); int newFileno = getNewFileno(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", newFileno, refCounter.get()); return new ChannelDescriptor(channel, newFileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
/** * Mimics the POSIX dup(2) function, returning a new descriptor that references * the same open channel. * * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup() { synchronized (refCounter) { refCounter.incrementAndGet(); int newFileno = getNewFileno(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", newFileno, refCounter.get()); return new ChannelDescriptor(channel, newFileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
/** * Mimics the POSIX dup(2) function, returning a new descriptor that references * the same open channel. * * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup() { synchronized (refCounter) { refCounter.incrementAndGet(); int newFileno = getNewFileno(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", newFileno, refCounter.get()); return new ChannelDescriptor(channel, newFileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
/** * Special constructor to create the ChannelDescriptor out of the stream, file number, * mode flags, and file descriptor object. The channel will be created from the * provided stream. The channel will be kept open until all ChannelDescriptor * references to it have been closed. <b>Note:</b> in most cases, you should not * use this constructor, it's reserved mostly for STDIN. * * @param baseInputStream The stream to create the channel for the new descriptor * @param originalModes The mode flags for the new descriptor */ public ChannelDescriptor(InputStream baseInputStream, ModeFlags originalModes) { // The reason why we need the stream is to be able to invoke available() on it. // STDIN in Java is non-interruptible, non-selectable, and attempt to read // on such stream might lead to thread being blocked without *any* way to unblock it. // That's where available() comes it, so at least we could check whether // anything is available to be read without blocking. this(Channels.newChannel(baseInputStream), getNewFileno(), originalModes, new FileDescriptor(), new AtomicInteger(1), true, false); this.baseInputStream = baseInputStream; }
/** * Special constructor to create the ChannelDescriptor out of the stream, file number, * mode flags, and file descriptor object. The channel will be created from the * provided stream. The channel will be kept open until all ChannelDescriptor * references to it have been closed. <b>Note:</b> in most cases, you should not * use this constructor, it's reserved mostly for STDIN. * * @param baseInputStream The stream to create the channel for the new descriptor * @param originalModes The mode flags for the new descriptor */ public ChannelDescriptor(InputStream baseInputStream, ModeFlags originalModes) { // The reason why we need the stream is to be able to invoke available() on it. // STDIN in Java is non-interruptible, non-selectable, and attempt to read // on such stream might lead to thread being blocked without *any* way to unblock it. // That's where available() comes it, so at least we could check whether // anything is available to be read without blocking. this(Channels.newChannel(baseInputStream), getNewFileno(), originalModes, new FileDescriptor(), new AtomicInteger(1), true, false); this.baseInputStream = baseInputStream; }