-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wisp] Blocking io support for SocketChannel and Pipe #35
[Wisp] Blocking io support for SocketChannel and Pipe #35
Conversation
59a63dc
to
80d1cb7
Compare
import java.nio.channels.SelectableChannel; | ||
import java.nio.channels.SelectionKey; | ||
import java.nio.channels.Selector; | ||
import java.nio.channels.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary change
import java.nio.channels.NotYetBoundException; | ||
import java.nio.channels.ServerSocketChannel; | ||
import java.nio.channels.SocketChannel; | ||
import java.nio.channels.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary change
80d1cb7
to
38d8b94
Compare
@@ -344,6 +344,25 @@ public void getCpuTime(long[] ids, long[] times) { | |||
} | |||
} | |||
} | |||
|
|||
@Override | |||
public int poll(SelectableChannel channel, int interestOps, long millsTimeOut) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- WAE.poll should return polled event count;
- WAE.poll receive NET.* events represent as parameters will be clearer.
- Coroutines are not interrupted when the socket closes. Leave a TODO there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. please have another look.
Close socket is ok here, because we would check isOpen() every time.
c2ddb40
to
9e76d2c
Compare
} | ||
} | ||
|
||
int translateToSelectionKey(int event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't use switch here because Net.POLLIN is not constant.
6a392db
to
1ae35b8
Compare
@@ -25,6 +25,8 @@ | |||
|
|||
package sun.nio.ch; | |||
|
|||
import com.alibaba.wisp.engine.WispEngine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
} | ||
|
||
@Override | ||
public int poll(SelectableChannel channel, int interestOps, long millsTimeOut) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add JavaDoc to point out it's a Net.* event represent
1ae35b8
to
69648f6
Compare
* @return active event count | ||
* @throws IOException | ||
*/ | ||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put the java doc above method in the interface
@@ -25,6 +25,7 @@ | |||
|
|||
package sun.nio.ch; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary
@@ -278,7 +271,9 @@ public SocketChannel accept() throws IOException { | |||
if (n < 1) | |||
return null; | |||
|
|||
IOUtil.configureBlocking(newfd, true); | |||
if (!WispEngine.transparentWispSwitch()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use configureAsNonBlockingForWisp
@@ -25,6 +25,7 @@ | |||
|
|||
package sun.nio.ch; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary
try { | ||
configureAsNonBlockingForWisp(fd); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Unexpected error at configureAsNonBlockingForWisp", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UncheckIOException
a6ef9e1
to
cb6933c
Compare
cb6933c
to
07926ed
Compare
@@ -165,6 +175,12 @@ public int read(ByteBuffer dst) throws IOException { | |||
thread = NativeThread.current(); | |||
do { | |||
n = IOUtil.read(fd, dst, -1, nd); | |||
if (isBlocking() && WispEngine.transparentWispSwitch()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WispEngine.transparentWispSwitch() && isBlocking()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
e210c92
to
4c95f4b
Compare
Summary: Hook blocking entry at pipeChannel and SocketChannel, current WispTask would block itself to wait for next scheduling. Test Plan: jtreg BlockIngIOTest. Reviewed-by: zhengxiaolinX, yuleil Issue: dragonwell-project/dragonwell8#143
4c95f4b
to
3b3d0cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch looks good to me.
Summary: Hook blocking entry at pipeChannel and SocketChannel,
current WispTask would block itself to wait for next scheduling.
Test Plan: jtreg BlockIngIOTest.
Reviewed-by: zhengxiaolinX, yuleil
Issue: dragonwell-project/dragonwell8#143