Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

flattened out that do/while loop that only ran once in DataChannelRer…#778

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jabrena merged 3 commits intoev3dev-lang-java:sysfs_perf2fromdwalend:channelBattery
Dec 31, 2020

Conversation

@dwalend
Copy link
Contributor

No description provided.

byteBuffer.clear();
channel.position(0);
intn =channel.read(byteBuffer);
if (n == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this branch should handle then == 0 case as well. I'm not sure when would this happen, but if it happens then the code below will break (bytes[-1] is invalid).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It is not a bad idea.
I will merge this version and later we will refine with that idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This was already added:c1b7897 (later commit in this PR)

}while (n <=0);
byteBuffer.clear();
channel.position(0);
intn =channel.read(byteBuffer);
Copy link
Contributor

@JakubVanekJakubVanekDec 30, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Theposition() +read() calls can be merged together:

With that change, all FileChannel accesses should be thread-safe (I think including close), only the buffer would be unsafe.

EDIT: javadocs:https://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#read(java.nio.ByteBuffer,%20long)

@jabrenajabrena merged commit433eaf3 intoev3dev-lang-java:sysfs_perf2Dec 31, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jabrenajabrenajabrena left review comments

+1 more reviewer

@JakubVanekJakubVanekJakubVanek left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@dwalend@jabrena@JakubVanek

[8]ページ先頭

©2009-2025 Movatter.jp