Last active
March 5, 2016 17:08
-
-
Save Jim-Lin/c365eb6431e3f8f2aeb0 to your computer and use it in GitHub Desktop.
[Netty] brief talk about Non-Blocking I/O ref: http://qiita.com/SHUAI/items/bea4b8621380b642f116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample code: | |
read(file, tmp_buf, len); | |
write(socket, tmp_buf, len); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample code: | |
tmp_buf = mmap(file, len); | |
write(socket, tmp_buf, len); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample code: | |
sendfile(socket, file, len); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Example { | |
public static void main(String... args) throws Exception { | |
ExecResult<String> result = ExecHarness.yieldSingle(c -> | |
Promise.value("foo") | |
.transform(up -> down -> | |
up.connect(down.<String>onSuccess(value -> { | |
try { | |
down.success(value.toUpperCase()); | |
} catch (Throwable e) { | |
down.error(e); | |
} | |
})) | |
) | |
); | |
assertEquals("FOO", result.getValue()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment