Skip to content

Commit

Permalink
Linux: use array element var handle
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelbl committed Dec 7, 2024
1 parent 62d3553 commit 393218f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ private EPoll() {}
JAVA_INT_UNALIGNED.withName("events"),
DATA$LAYOUT.withName("data")).withName("epoll_event");

// varhandle to access the "fd" field in an epoll_event array
static final VarHandle EVENT_ARRAY_DATA_FD$VH = EVENT$LAYOUT.arrayElementVarHandle(
MemoryLayout.PathElement.groupElement("data"),
MemoryLayout.PathElement.groupElement("fd")
);

// varhandle to access the "fd" field in an epoll_event struct
static final VarHandle EVENT_DATA_FD$VH = EVENT$LAYOUT.varHandle(
private static final VarHandle EVENT_DATA_FD$VH = EVENT$LAYOUT.varHandle(
MemoryLayout.PathElement.groupElement("data"),
MemoryLayout.PathElement.groupElement("fd")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ private void asyncCompletionTask() {

// for all ready file descriptors, reap URBs
for (int i = 0; i < res; i++) {
var event = events.asSlice(i * EPoll.EVENT$LAYOUT.byteSize(), EPoll.EVENT$LAYOUT);
var fd = (int) EPoll.EVENT_DATA_FD$VH.get(event, 0L);
var fd = (int) EPoll.EVENT_ARRAY_DATA_FD$VH.get(events, 0L, i);
reapURBs(fd, urbPointerHolder, errorState);
}
}
Expand Down

0 comments on commit 393218f

Please sign in to comment.