Skip to content

Channel reset - #756

Merged
jabrena merged 6 commits into
ev3dev-lang-java:sysfs_perffrom
dwalend:channelReset
Dec 13, 2020
Merged

jabrena merged 6 commits into
ev3dev-lang-java:sysfs_perffrom
dwalend:channelReset

Conversation

@dwalend

@dwalend dwalend commented Dec 11, 2020

Copy link
Copy Markdown
Contributor

I've created DataChannelRereader - a Closable wrapped around a FileChannel that lets us reread the same fixed-length structure very efficiently.

I've used it (without reusing it) in Sysfs2, to read Strings as a first step. From here I can expand outward into the device and mode APIs to reuse it for specific optimizations, and add to DataChannelRereader to support binary data, as incremental steps.

do {
byteBuffer.clear();
channel.position(0);
n = channel.read(byteBuffer);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this could be simplified to a channel.read(byteBuffer, 0) call. However, it's entirely possible that under the hood the two-arg read is just the following, which could be slower:

int old = channel.position();
channel.position(0);
int rval = channel.read(buffer);
channel.position(old);
return rval;

@jabrena
jabrena merged commit 5bc8f1b into ev3dev-lang-java:sysfs_perf Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants