File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
java-does-usb/src/main/java/net/codecrete/usb/linux Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,14 @@ private EPoll() {}
50
50
JAVA_INT_UNALIGNED .withName ("events" ),
51
51
DATA$LAYOUT .withName ("data" )).withName ("epoll_event" );
52
52
53
+ // varhandle to access the "fd" field in an epoll_event array
54
+ static final VarHandle EVENT_ARRAY_DATA_FD$VH = EVENT$LAYOUT .arrayElementVarHandle (
55
+ MemoryLayout .PathElement .groupElement ("data" ),
56
+ MemoryLayout .PathElement .groupElement ("fd" )
57
+ );
58
+
53
59
// varhandle to access the "fd" field in an epoll_event struct
54
- static final VarHandle EVENT_DATA_FD$VH = EVENT$LAYOUT .varHandle (
60
+ private static final VarHandle EVENT_DATA_FD$VH = EVENT$LAYOUT .varHandle (
55
61
MemoryLayout .PathElement .groupElement ("data" ),
56
62
MemoryLayout .PathElement .groupElement ("fd" )
57
63
);
Original file line number Diff line number Diff line change @@ -98,8 +98,7 @@ private void asyncCompletionTask() {
98
98
99
99
// for all ready file descriptors, reap URBs
100
100
for (int i = 0 ; i < res ; i ++) {
101
- var event = events .asSlice (i * EPoll .EVENT$LAYOUT .byteSize (), EPoll .EVENT$LAYOUT );
102
- var fd = (int ) EPoll .EVENT_DATA_FD$VH .get (event , 0L );
101
+ var fd = (int ) EPoll .EVENT_ARRAY_DATA_FD$VH .get (events , 0L , i );
103
102
reapURBs (fd , urbPointerHolder , errorState );
104
103
}
105
104
}
You can’t perform that action at this time.
0 commit comments