mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8318422: Allow poller threads be virtual threads
Reviewed-by: michaelm
This commit is contained in:
parent
29cf2c471b
commit
c099cf53f2
13 changed files with 368 additions and 399 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,12 +33,12 @@ class DefaultPollerProvider extends PollerProvider {
|
|||
DefaultPollerProvider() { }
|
||||
|
||||
@Override
|
||||
Poller readPoller() throws IOException {
|
||||
return new KQueuePoller(true);
|
||||
Poller readPoller(boolean subPoller) throws IOException {
|
||||
return new KQueuePoller(subPoller, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
Poller writePoller() throws IOException {
|
||||
return new KQueuePoller(false);
|
||||
Poller writePoller(boolean subPoller) throws IOException {
|
||||
return new KQueuePoller(subPoller, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,17 +31,16 @@ import static sun.nio.ch.KQueue.*;
|
|||
* Poller implementation based on the kqueue facility.
|
||||
*/
|
||||
class KQueuePoller extends Poller {
|
||||
private static final int MAX_EVENTS_TO_POLL = 512;
|
||||
|
||||
private final int kqfd;
|
||||
private final int filter;
|
||||
private final int maxEvents;
|
||||
private final long address;
|
||||
|
||||
KQueuePoller(boolean read) throws IOException {
|
||||
super(read);
|
||||
KQueuePoller(boolean subPoller, boolean read) throws IOException {
|
||||
this.kqfd = KQueue.create();
|
||||
this.filter = (read) ? EVFILT_READ : EVFILT_WRITE;
|
||||
this.address = KQueue.allocatePollArray(MAX_EVENTS_TO_POLL);
|
||||
this.maxEvents = (subPoller) ? 64 : 512;
|
||||
this.address = KQueue.allocatePollArray(maxEvents);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,7 +62,7 @@ class KQueuePoller extends Poller {
|
|||
|
||||
@Override
|
||||
int poll(int timeout) throws IOException {
|
||||
int n = KQueue.poll(kqfd, address, MAX_EVENTS_TO_POLL, timeout);
|
||||
int n = KQueue.poll(kqfd, address, maxEvents, timeout);
|
||||
int i = 0;
|
||||
while (i < n) {
|
||||
long keventAddress = KQueue.getEvent(address, i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue