mirror of
https://github.com/corda/corda.git
synced 2025-06-14 13:18:18 +00:00
Implemented a basic NIO socket channel interface. Non-blocking socket channels
and server socket channels are implemented. This version works but only when libnative is linked with g++ (because of C++ object creation code that fails without this linking)
This commit is contained in:
28
classpath/java/nio/channels/SelectableChannel.java
Normal file
28
classpath/java/nio/channels/SelectableChannel.java
Normal file
@ -0,0 +1,28 @@
|
||||
package java.nio.channels;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public abstract class SelectableChannel implements Channel {
|
||||
private SelectionKey key;
|
||||
|
||||
public abstract int read(ByteBuffer b) throws Exception;
|
||||
public abstract int write(ByteBuffer b) throws Exception;
|
||||
public abstract boolean isOpen();
|
||||
|
||||
public SelectionKey register(Selector selector, int interestOps,
|
||||
Object attachment)
|
||||
{
|
||||
SelectionKey key = new SelectionKey
|
||||
(this, selector, interestOps, attachment);
|
||||
selector.add(key);
|
||||
return key;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (key != null) {
|
||||
key.selector().remove(key);
|
||||
key = null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user