|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object gnu.java.nio.VMChannel
public final class VMChannel
Native interface to support configuring of channel to run in a non-blocking manner and support scatter/gather io operations. JikesRVM-specific implementation by Robin Garner and Filip Pizlo.
Nested Class Summary | |
---|---|
(package private) static class |
VMChannel.Kind
An enumeration of possible kinds of channel. |
private static class |
VMChannel.LocalByteArray
A thread-local store of non-moving buffers. |
class |
VMChannel.State
A wrapper for a native file descriptor integer. |
Field Summary | |
---|---|
private VMChannel.Kind |
kind
|
private static VMChannel.LocalByteArray |
localByteArray
Thread-local buffer for VM-side buffering of write calls |
private static int |
MAX_STANDARD_FD
Don't do fast I/O for the standard file descriptors - these are used for throwing exceptions, so may not be able to allocate. |
private VMChannel.State |
nfd
Our reference implementation uses an integer to store the native file descriptor. |
Constructor Summary | |
---|---|
VMChannel()
|
|
VMChannel(int native_fd)
This constructor is used by the POSIX reference implementation; other virtual machines need not support it. |
Method Summary | |
---|---|
VMChannel |
accept()
Accept an incoming connection, returning a new VMChannel, or null if the channel is nonblocking and no connection is pending. |
private static int |
accept(int native_fd)
|
int |
available()
|
private static int |
available(int native_fd)
|
void |
close()
Close this socket. |
(package private) static void |
close(int native_fd)
|
boolean |
connect(InetSocketAddress saddr,
int timeout)
Connect the underlying socket file descriptor to the remote host. |
private static boolean |
connect(int fd,
byte[] addr,
int port,
int timeout)
|
private static boolean |
connect6(int fd,
byte[] addr,
int port,
int timeout)
|
void |
disconnect()
Disconnect this channel, if it is a datagram socket. |
private static void |
disconnect(int fd)
|
boolean |
flush(boolean metadata)
|
private static boolean |
flush(int fd,
boolean metadata)
|
InetSocketAddress |
getLocalAddress()
|
InetSocketAddress |
getPeerAddress()
Returns the socket address of the remote peer this channel is connected to, or null if this channel is not yet connected. |
private static int |
getpeername(int fd,
ByteBuffer name)
|
private static int |
getsockname(int fd,
ByteBuffer name)
|
VMChannel.State |
getState()
|
static VMChannel |
getStderr()
|
static VMChannel |
getStdin()
|
static VMChannel |
getStdout()
|
private static void |
initIDs()
|
void |
initSocket(boolean stream)
Create a new socket. |
(package private) static boolean |
isThreadInterrupted()
Provides a simple mean for the JNI code to find out whether the current thread was interrupted by a call to Thread.interrupt(). |
private static boolean |
lock(int fd,
long pos,
long len,
boolean shared,
boolean wait)
|
boolean |
lock(long pos,
long len,
boolean shared,
boolean wait)
|
MappedByteBuffer |
map(char mode,
long position,
int size)
|
private static MappedByteBuffer |
map(int fd,
char mode,
long position,
int size)
|
private static int |
max(int[] values)
|
private static int |
open(String path,
int mode)
|
void |
openFile(String path,
int mode)
Open a file at PATH, initializing the native state to operate on that open file. |
long |
position()
|
private static long |
position(int fd)
|
int |
read()
Read a single byte. |
private int |
read(byte[] dst,
int pos,
int len)
Reads a byte array directly. |
int |
read(ByteBuffer dst)
Read the specified byte buffer. |
private int |
read(ByteBuffer dst,
int pos,
int len)
Read a byte buffer, given a starting position and length. |
private static int |
read(int fd)
|
private static int |
read(int fd,
byte[] dst,
int position,
int len)
Use JikesRVM's internal read function - the fast way. |
private static int |
read(int fd,
ByteBuffer dst)
Classpath's native read method. |
long |
readScattering(ByteBuffer[] dsts,
int offset,
int length)
Reads into byte buffers directly using the supplied file descriptor. |
private static long |
readScattering(int fd,
ByteBuffer[] dsts,
int offset,
int length)
|
SocketAddress |
receive(ByteBuffer dst)
Receive a datagram on this channel, returning the host address that sent the datagram. |
private static int |
receive(int fd,
ByteBuffer dst,
ByteBuffer address)
|
private static void |
seek(int fd,
long pos)
|
void |
seek(long pos)
|
int |
send(ByteBuffer src,
InetSocketAddress dst)
Send a datagram to the given address. |
private static int |
send(int fd,
ByteBuffer src,
byte[] addr,
int port)
|
private static int |
send6(int fd,
ByteBuffer src,
byte[] addr,
int port)
|
void |
setBlocking(boolean blocking)
Set the file descriptor to have the required blocking setting. |
private static void |
setBlocking(int fd,
boolean blocking)
|
long |
size()
|
private static long |
size(int fd)
|
private static int |
socket(boolean stream)
Create a new socket, returning the native file descriptor. |
private static int |
stderr_fd()
|
private static int |
stdin_fd()
|
private static int |
stdout_fd()
|
private static void |
truncate(int fd,
long len)
|
void |
truncate(long length)
|
private static void |
unlock(int fd,
long pos,
long len)
|
void |
unlock(long pos,
long len)
|
int |
write(byte[] src,
int pos,
int len)
Writes from a byte array using the supplied file descriptor. |
int |
write(ByteBuffer src)
|
int |
write(ByteBuffer src,
int pos,
int len)
|
void |
write(int b)
Write a single byte. |
private static int |
write(int fd,
byte[] src,
int pos,
int len)
Use JikesRVM's internal read function - the fast way. |
private static int |
write(int fd,
ByteBuffer src)
Classpath's native write method. |
private static void |
write(int fd,
int b)
|
long |
writeGathering(ByteBuffer[] srcs,
int offset,
int length)
Writes from byte buffers directly using the supplied file descriptor. |
private long |
writeGathering(int fd,
ByteBuffer[] srcs,
int offset,
int length)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final VMChannel.State nfd
private VMChannel.Kind kind
private static int MAX_STANDARD_FD
private static final VMChannel.LocalByteArray localByteArray
Constructor Detail |
---|
public VMChannel()
VMChannel(int native_fd) throws IOException
native_fd
- The native file descriptor integer.
IOException
Method Detail |
---|
public VMChannel.State getState()
private static int max(int[] values)
public static VMChannel getStdin() throws IOException
IOException
public static VMChannel getStdout() throws IOException
IOException
public static VMChannel getStderr() throws IOException
IOException
private static int stdin_fd()
private static int stdout_fd()
private static int stderr_fd()
public void setBlocking(boolean blocking) throws IOException
blocking
- The blocking flag to set.
IOException
private static void setBlocking(int fd, boolean blocking) throws IOException
IOException
public int available() throws IOException
IOException
private static int available(int native_fd) throws IOException
IOException
public int read(ByteBuffer dst) throws IOException
dst
-
IOException
private int read(ByteBuffer dst, int pos, int len) throws IOException
dst
- pos
- len
-
IOException
private int read(byte[] dst, int pos, int len) throws IOException
dst
- Byte array to read to
IOException
- If an error occurs or dst is not a direct buffers.private static int read(int fd, byte[] dst, int position, int len) throws IOException
fd
- File descriptordst
- Destination bufferposition
- Starting offset in the bufferlen
- Number of bytes to read
IOException
private static int read(int fd, ByteBuffer dst) throws IOException
fd
- dst
-
IOException
public int read() throws IOException
IOException
private static int read(int fd) throws IOException
IOException
public long readScattering(ByteBuffer[] dsts, int offset, int length) throws IOException
dsts
- An array direct byte buffers.offset
- Index of the first buffer to read to.length
- The number of buffers to read to.
IOException
- If an error occurs or the dsts are not direct buffers.private static long readScattering(int fd, ByteBuffer[] dsts, int offset, int length) throws IOException
IOException
public SocketAddress receive(ByteBuffer dst) throws IOException
dst
- Where to store the datagram.
IOException
private static int receive(int fd, ByteBuffer dst, ByteBuffer address) throws IOException
IOException
public int write(byte[] src, int pos, int len) throws IOException
src
- The source buffer.
IOException
public int write(ByteBuffer src, int pos, int len) throws IOException
IOException
public int write(ByteBuffer src) throws IOException
IOException
private static int write(int fd, byte[] src, int pos, int len) throws IOException
fd
- File descriptorsrc
- SOurce bufferpos
- Starting offset in the bufferlen
- Number of bytes to write
IOException
private static int write(int fd, ByteBuffer src) throws IOException
fd
- src
-
IOException
public long writeGathering(ByteBuffer[] srcs, int offset, int length) throws IOException
srcs
- offset
- length
-
IOException
private long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length) throws IOException
IOException
public int send(ByteBuffer src, InetSocketAddress dst) throws IOException
src
- The source buffer.dst
- The destination address.
IOException
private static int send(int fd, ByteBuffer src, byte[] addr, int port) throws IOException
IOException
private static int send6(int fd, ByteBuffer src, byte[] addr, int port) throws IOException
IOException
public void write(int b) throws IOException
b
- The byte to write.
IOException
private static void write(int fd, int b) throws IOException
IOException
private static void initIDs()
public void initSocket(boolean stream) throws IOException
stream
- Whether or not to create a streaming socket, or a datagram
socket.
IOException
- If creating a new socket fails, or if this
channel already has its native descriptor initialized.private static int socket(boolean stream) throws IOException
stream
- Set to true for streaming sockets; false for datagrams.
IOException
- If creating the socket fails.public boolean connect(InetSocketAddress saddr, int timeout) throws SocketException
saddr
- The address to connect to.timeout
- The connect timeout to use for blocking connects.
IOException
- If an error occurs while connecting.
SocketException
private static boolean connect(int fd, byte[] addr, int port, int timeout) throws SocketException
SocketException
private static boolean connect6(int fd, byte[] addr, int port, int timeout) throws SocketException
SocketException
public void disconnect() throws IOException
IOException
- If disconnecting this channel fails, or if this
channel is not a datagram channel.private static void disconnect(int fd) throws IOException
IOException
public InetSocketAddress getLocalAddress() throws IOException
IOException
private static int getsockname(int fd, ByteBuffer name) throws IOException
IOException
public InetSocketAddress getPeerAddress() throws IOException
IOException
private static int getpeername(int fd, ByteBuffer name) throws IOException
IOException
public VMChannel accept() throws IOException
IOException
- If an IO error occurs.private static int accept(int native_fd) throws IOException
IOException
public void openFile(String path, int mode) throws IOException
path
- The absolute file path.
IOException
- If the file cannot be opened, or if this
channel was previously initialized.private static int open(String path, int mode) throws IOException
IOException
public long position() throws IOException
IOException
private static long position(int fd) throws IOException
IOException
public void seek(long pos) throws IOException
IOException
private static void seek(int fd, long pos) throws IOException
IOException
public void truncate(long length) throws IOException
IOException
private static void truncate(int fd, long len) throws IOException
IOException
public boolean lock(long pos, long len, boolean shared, boolean wait) throws IOException
IOException
private static boolean lock(int fd, long pos, long len, boolean shared, boolean wait) throws IOException
IOException
public void unlock(long pos, long len) throws IOException
IOException
private static void unlock(int fd, long pos, long len) throws IOException
IOException
public long size() throws IOException
IOException
private static long size(int fd) throws IOException
IOException
public MappedByteBuffer map(char mode, long position, int size) throws IOException
IOException
private static MappedByteBuffer map(int fd, char mode, long position, int size) throws IOException
IOException
public boolean flush(boolean metadata) throws IOException
IOException
private static boolean flush(int fd, boolean metadata) throws IOException
IOException
public void close() throws IOException
IOException
- If closing the socket fails, or if this object has
no open socket.static void close(int native_fd) throws IOException
IOException
static boolean isThreadInterrupted()
Provides a simple mean for the JNI code to find out whether the current thread was interrupted by a call to Thread.interrupt().
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |