[foreign-memaccess+abi] RFR: 8264933: Improve stream support in memory segments
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu Apr 8 21:19:47 UTC 2021
This patch improves stream support for memory segments - it does so in two ways:
* first, tweaking the `MemorySegment::spliterator` method to take an *element layout*, instead of a full sequence layout whose size had to match that of the segment.
* secondly, by adding convenience methods to create streams directly, w/o needing to call `StreamSupport.stream`. As for `Collection`, two methods are provided: `MemorySegment::stream` and `MemorySegment::parallelStream`.
I've fixed up the documentation in places - I realized that, for example, the javadoc for `MemorySegment::spliterator` was missing a `@throws` clause for when there's a size mismatch between layout and segment.
Also, I've removed scope liveness check on the spliterator call - after all, a spliterator is going to make slices - a liveness check will occur when the slice is accessed.
-------------
Commit messages:
- Fix javadoc sample
- Initial push
Changes: https://git.openjdk.java.net/panama-foreign/pull/494/files
Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=494&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8264933
Stats: 77 lines in 5 files changed: 40 ins; 4 del; 33 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/494.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/494/head:pull/494
PR: https://git.openjdk.java.net/panama-foreign/pull/494
More information about the panama-dev
mailing list