8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package sun.nio.ch;
26
27 import java.io.IOException;
28 import java.util.Arrays;
29 import java.util.List;
30 import java.util.Map;
31 import java.util.Objects;
32 import java.util.concurrent.ConcurrentHashMap;
33 import java.util.concurrent.Executor;
34 import java.util.concurrent.Executors;
35 import java.util.concurrent.ThreadFactory;
36 import java.util.concurrent.locks.LockSupport;
37 import java.util.function.BooleanSupplier;
38 import jdk.internal.misc.InnocuousThread;
39 import jdk.internal.vm.annotation.Stable;
40
41 /**
42 * Polls file descriptors. Virtual threads invoke the poll method to park
43 * until a given file descriptor is ready for I/O.
44 */
45 public abstract class Poller {
46 private static final Pollers POLLERS;
47 static {
48 try {
49 var pollers = new Pollers();
50 pollers.start();
51 POLLERS = pollers;
52 } catch (IOException ioe) {
53 throw new ExceptionInInitializerError(ioe);
54 }
55 }
56
57 // the poller or sub-poller thread
58 private @Stable Thread owner;
59
60 // maps file descriptors to parked Thread
61 private final Map<Integer, Thread> map = new ConcurrentHashMap<>();
62
63 /**
64 * Poller mode.
65 */
66 enum Mode {
67 /**
68 * ReadPoller and WritePoller are dedicated platform threads that block waiting
69 * for events and unpark virtual threads when file descriptors are ready for I/O.
70 */
71 SYSTEM_THREADS,
72
73 /**
74 * ReadPoller and WritePoller threads are virtual threads that poll for events,
75 * yielding between polls and unparking virtual threads when file descriptors are
121 abstract int poll(int timeout) throws IOException;
122
123 /**
124 * Callback by the poll method when a file descriptor is polled.
125 */
126 final void polled(int fdVal) {
127 wakeup(fdVal);
128 }
129
130 /**
131 * Parks the current thread until a file descriptor is ready for the given op.
132 * @param fdVal the file descriptor
133 * @param event POLLIN or POLLOUT
134 * @param nanos the waiting time or 0 to wait indefinitely
135 * @param supplier supplies a boolean to indicate if the enclosing object is open
136 */
137 static void poll(int fdVal, int event, long nanos, BooleanSupplier supplier)
138 throws IOException
139 {
140 assert nanos >= 0L;
141 if (event == Net.POLLIN) {
142 POLLERS.readPoller(fdVal).poll(fdVal, nanos, supplier);
143 } else if (event == Net.POLLOUT) {
144 POLLERS.writePoller(fdVal).poll(fdVal, nanos, supplier);
145 } else {
146 assert false;
147 }
148 }
149
150 /**
151 * Parks the current thread until a Selector's file descriptor is ready.
152 * @param fdVal the Selector's file descriptor
153 * @param nanos the waiting time or 0 to wait indefinitely
154 */
155 static void pollSelector(int fdVal, long nanos) throws IOException {
156 assert nanos >= 0L;
157 Poller poller = POLLERS.masterPoller();
158 if (poller == null) {
159 poller = POLLERS.readPoller(fdVal);
160 }
161 poller.poll(fdVal, nanos, () -> true);
162 }
163
164 /**
165 * If there is a thread polling the given file descriptor for the given event then
166 * the thread is unparked.
167 */
168 static void stopPoll(int fdVal, int event) {
169 if (event == Net.POLLIN) {
170 POLLERS.readPoller(fdVal).wakeup(fdVal);
171 } else if (event == Net.POLLOUT) {
172 POLLERS.writePoller(fdVal).wakeup(fdVal);
173 } else {
174 throw new IllegalArgumentException();
175 }
176 }
177
178 /**
179 * If there are any threads polling the given file descriptor then they are unparked.
180 */
181 static void stopPoll(int fdVal) {
182 stopPoll(fdVal, Net.POLLIN);
183 stopPoll(fdVal, Net.POLLOUT);
184 }
185
186 /**
187 * Parks the current thread until a file descriptor is ready.
188 */
189 private void poll(int fdVal, long nanos, BooleanSupplier supplier) throws IOException {
190 register(fdVal);
191 try {
192 boolean isOpen = supplier.getAsBoolean();
193 if (isOpen) {
194 if (nanos > 0) {
195 LockSupport.parkNanos(nanos);
196 } else {
197 LockSupport.park();
198 }
199 }
200 } finally {
201 deregister(fdVal);
202 }
203 }
262 * with fairness and to avoid re-registering with the master poller where possible.
263 */
264 private void subPollerLoop(Poller masterPoller) {
265 assert Thread.currentThread().isVirtual();
266 owner = Thread.currentThread();
267 try {
268 int polled = 0;
269 for (;;) {
270 if (polled == 0) {
271 masterPoller.poll(fdVal(), 0, () -> true); // park
272 } else {
273 Thread.yield();
274 }
275 polled = poll(0);
276 }
277 } catch (Exception e) {
278 e.printStackTrace();
279 }
280 }
281
282 /**
283 * Returns the number I/O operations currently registered with this poller.
284 */
285 public int registered() {
286 return map.size();
287 }
288
289 @Override
290 public String toString() {
291 return String.format("%s [registered = %d, owner = %s]",
292 Objects.toIdentityString(this), registered(), owner);
293 }
294
295 /**
296 * The Pollers used for read and write events.
297 */
298 private static class Pollers {
299 private final PollerProvider provider;
300 private final Poller.Mode pollerMode;
301 private final Poller masterPoller;
302 private final Poller[] readPollers;
303 private final Poller[] writePollers;
304
305 // used by start method to executor is kept alive
306 private Executor executor;
307
308 /**
309 * Creates the Poller instances based on configuration.
310 */
311 Pollers() throws IOException {
312 PollerProvider provider = PollerProvider.provider();
313 Poller.Mode mode;
314 String s = System.getProperty("jdk.pollerMode");
315 if (s != null) {
316 if (s.equalsIgnoreCase(Mode.SYSTEM_THREADS.name()) || s.equals("1")) {
317 mode = Mode.SYSTEM_THREADS;
318 } else if (s.equalsIgnoreCase(Mode.VTHREAD_POLLERS.name()) || s.equals("2")) {
319 mode = Mode.VTHREAD_POLLERS;
320 } else {
321 throw new RuntimeException("Can't parse '" + s + "' as polling mode");
322 }
323 } else {
324 mode = provider.defaultPollerMode();
325 }
326
327 // vthread poller mode needs a master poller
328 Poller masterPoller = (mode == Mode.VTHREAD_POLLERS)
329 ? provider.readPoller(false)
330 : null;
331
332 // read pollers (or sub-pollers)
333 int readPollerCount = pollerCount("jdk.readPollers", provider.defaultReadPollers(mode));
334 Poller[] readPollers = new Poller[readPollerCount];
335 for (int i = 0; i < readPollerCount; i++) {
336 readPollers[i] = provider.readPoller(mode == Mode.VTHREAD_POLLERS);
337 }
338
339 // write pollers (or sub-pollers)
340 int writePollerCount = pollerCount("jdk.writePollers", provider.defaultWritePollers(mode));
341 Poller[] writePollers = new Poller[writePollerCount];
342 for (int i = 0; i < writePollerCount; i++) {
343 writePollers[i] = provider.writePoller(mode == Mode.VTHREAD_POLLERS);
344 }
345
346 this.provider = provider;
347 this.pollerMode = mode;
348 this.masterPoller = masterPoller;
349 this.readPollers = readPollers;
350 this.writePollers = writePollers;
351 }
352
353 /**
354 * Starts the Poller threads.
355 */
356 void start() {
357 if (pollerMode == Mode.VTHREAD_POLLERS) {
358 startPlatformThread("MasterPoller", masterPoller::pollerLoop);
359 ThreadFactory factory = Thread.ofVirtual()
360 .inheritInheritableThreadLocals(false)
361 .name("SubPoller-", 0)
362 .uncaughtExceptionHandler((t, e) -> e.printStackTrace())
363 .factory();
364 executor = Executors.newThreadPerTaskExecutor(factory);
365 Arrays.stream(readPollers).forEach(p -> {
366 executor.execute(() -> p.subPollerLoop(masterPoller));
367 });
368 Arrays.stream(writePollers).forEach(p -> {
369 executor.execute(() -> p.subPollerLoop(masterPoller));
370 });
371 } else {
372 Arrays.stream(readPollers).forEach(p -> {
373 startPlatformThread("Read-Poller", p::pollerLoop);
374 });
375 Arrays.stream(writePollers).forEach(p -> {
376 startPlatformThread("Write-Poller", p::pollerLoop);
377 });
378 }
379 }
380
381 /**
382 * Returns the master poller, or null if there is no master poller.
383 */
384 Poller masterPoller() {
385 return masterPoller;
386 }
387
388 /**
389 * Returns the read poller for the given file descriptor.
390 */
391 Poller readPoller(int fdVal) {
392 int index = provider.fdValToIndex(fdVal, readPollers.length);
393 return readPollers[index];
394 }
395
396 /**
397 * Returns the write poller for the given file descriptor.
398 */
399 Poller writePoller(int fdVal) {
400 int index = provider.fdValToIndex(fdVal, writePollers.length);
401 return writePollers[index];
402 }
403
404 /**
405 * Return the list of read pollers.
406 */
407 List<Poller> readPollers() {
408 return List.of(readPollers);
409 }
410
411 /**
412 * Return the list of write pollers.
413 */
414 List<Poller> writePollers() {
415 return List.of(writePollers);
416 }
417
418
419 /**
420 * Reads the given property name to get the poller count. If the property is
421 * set then the value must be a power of 2. Returns 1 if the property is not
422 * set.
423 * @throws IllegalArgumentException if the property is set to a value that
424 * is not a power of 2.
425 */
426 private static int pollerCount(String propName, int defaultCount) {
427 String s = System.getProperty(propName);
428 int count = (s != null) ? Integer.parseInt(s) : defaultCount;
429
430 // check power of 2
431 if (count != Integer.highestOneBit(count)) {
432 String msg = propName + " is set to a value that is not a power of 2";
433 throw new IllegalArgumentException(msg);
434 }
435 return count;
436 }
437
438 /**
439 * Starts a platform thread to run the given task.
440 */
441 private void startPlatformThread(String name, Runnable task) {
442 try {
443 Thread thread = InnocuousThread.newSystemThread(name, task);
444 thread.setDaemon(true);
445 thread.setUncaughtExceptionHandler((t, e) -> e.printStackTrace());
446 thread.start();
447 } catch (Exception e) {
448 throw new InternalError(e);
449 }
450 }
451 }
452
453 /**
454 * Return the master poller or null if there is no master poller.
455 */
456 public static Poller masterPoller() {
457 return POLLERS.masterPoller();
458 }
459
460 /**
461 * Return the list of read pollers.
462 */
463 public static List<Poller> readPollers() {
464 return POLLERS.readPollers();
465 }
466
467 /**
468 * Return the list of write pollers.
469 */
470 public static List<Poller> writePollers() {
471 return POLLERS.writePollers();
472 }
473 }
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package sun.nio.ch;
26
27 import java.io.IOException;
28 import java.io.UncheckedIOException;
29 import java.util.Arrays;
30 import java.util.List;
31 import java.util.Map;
32 import java.util.Objects;
33 import java.util.concurrent.ConcurrentHashMap;
34 import java.util.concurrent.Executor;
35 import java.util.concurrent.Executors;
36 import java.util.concurrent.ThreadFactory;
37 import java.util.concurrent.locks.LockSupport;
38 import java.util.function.BooleanSupplier;
39 import java.util.function.Supplier;
40 import jdk.internal.access.JavaLangAccess;
41 import jdk.internal.access.SharedSecrets;
42 import jdk.internal.misc.InnocuousThread;
43 import jdk.internal.vm.annotation.Stable;
44
45 /**
46 * Polls file descriptors. Virtual threads invoke the poll method to park
47 * until a given file descriptor is ready for I/O.
48 */
49 public abstract class Poller {
50 private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
51
52 private static final PollerProvider PROVIDER = PollerProvider.provider();
53
54 private static final Executor DEFAULT_SCHEDULER = JLA.virtualThreadDefaultScheduler();
55
56 private static Supplier<Mode> POLLER_MODE = StableValue.supplier(Poller::pollerMode);
57
58 private static Supplier<PollerGroup> DEFAULT_POLLER_GROUP = StableValue.supplier(PollerGroup::create);
59
60 // maps scheduler to PollerGroup, custom schedulers can't be GC'ed at this time
61 private static final Map<Executor, PollerGroup> POLLER_GROUPS = new ConcurrentHashMap<>();
62
63 // the poller or sub-poller thread
64 private @Stable Thread owner;
65
66 // maps file descriptors to parked Thread
67 private final Map<Integer, Thread> map = new ConcurrentHashMap<>();
68
69 /**
70 * Poller mode.
71 */
72 enum Mode {
73 /**
74 * ReadPoller and WritePoller are dedicated platform threads that block waiting
75 * for events and unpark virtual threads when file descriptors are ready for I/O.
76 */
77 SYSTEM_THREADS,
78
79 /**
80 * ReadPoller and WritePoller threads are virtual threads that poll for events,
81 * yielding between polls and unparking virtual threads when file descriptors are
127 abstract int poll(int timeout) throws IOException;
128
129 /**
130 * Callback by the poll method when a file descriptor is polled.
131 */
132 final void polled(int fdVal) {
133 wakeup(fdVal);
134 }
135
136 /**
137 * Parks the current thread until a file descriptor is ready for the given op.
138 * @param fdVal the file descriptor
139 * @param event POLLIN or POLLOUT
140 * @param nanos the waiting time or 0 to wait indefinitely
141 * @param supplier supplies a boolean to indicate if the enclosing object is open
142 */
143 static void poll(int fdVal, int event, long nanos, BooleanSupplier supplier)
144 throws IOException
145 {
146 assert nanos >= 0L;
147 PollerGroup pollerGroup = PollerGroup.groupFor(Thread.currentThread());
148 if (event == Net.POLLIN) {
149 pollerGroup.readPoller(fdVal).poll(fdVal, nanos, supplier);
150 } else if (event == Net.POLLOUT) {
151 pollerGroup.writePoller(fdVal).poll(fdVal, nanos, supplier);
152 } else {
153 assert false;
154 }
155 }
156
157 /**
158 * Parks the current thread until a Selector's file descriptor is ready.
159 * @param fdVal the Selector's file descriptor
160 * @param nanos the waiting time or 0 to wait indefinitely
161 */
162 static void pollSelector(int fdVal, long nanos) throws IOException {
163 assert nanos >= 0L;
164 PollerGroup pollerGroup = PollerGroup.groupFor(Thread.currentThread());
165 Poller poller = pollerGroup.masterPoller();
166 if (poller == null) {
167 poller = pollerGroup.readPoller(fdVal);
168 }
169 poller.poll(fdVal, nanos, () -> true);
170 }
171
172 /**
173 * Unpark the given thread so that it stops polling.
174 */
175 static void stopPoll(Thread thread) {
176 LockSupport.unpark(thread);
177 }
178
179 /**
180 * Parks the current thread until a file descriptor is ready.
181 */
182 private void poll(int fdVal, long nanos, BooleanSupplier supplier) throws IOException {
183 register(fdVal);
184 try {
185 boolean isOpen = supplier.getAsBoolean();
186 if (isOpen) {
187 if (nanos > 0) {
188 LockSupport.parkNanos(nanos);
189 } else {
190 LockSupport.park();
191 }
192 }
193 } finally {
194 deregister(fdVal);
195 }
196 }
255 * with fairness and to avoid re-registering with the master poller where possible.
256 */
257 private void subPollerLoop(Poller masterPoller) {
258 assert Thread.currentThread().isVirtual();
259 owner = Thread.currentThread();
260 try {
261 int polled = 0;
262 for (;;) {
263 if (polled == 0) {
264 masterPoller.poll(fdVal(), 0, () -> true); // park
265 } else {
266 Thread.yield();
267 }
268 polled = poll(0);
269 }
270 } catch (Exception e) {
271 e.printStackTrace();
272 }
273 }
274
275 @Override
276 public String toString() {
277 return String.format("%s [registered = %d, owner = %s]",
278 Objects.toIdentityString(this), map.size(), owner);
279 }
280
281 /**
282 * The read/write pollers.
283 */
284 private static class PollerGroup {
285 private final Executor scheduler;
286 private final Poller[] readPollers;
287 private final Poller[] writePollers;
288 private final Poller masterPoller;
289 private final Executor executor;
290
291 PollerGroup(Executor scheduler) throws IOException {
292 Mode mode = Poller.POLLER_MODE.get();
293 int readPollerCount, writePollerCount;
294 Poller masterPoller;
295 if (scheduler == DEFAULT_SCHEDULER) {
296 readPollerCount = pollerCount("jdk.readPollers", PROVIDER.defaultReadPollers(mode));
297 writePollerCount = pollerCount("jdk.writePollers", PROVIDER.defaultWritePollers(mode));
298 masterPoller = (mode == Mode.VTHREAD_POLLERS)
299 ? PROVIDER.readPoller(false)
300 : null;
301 } else {
302 readPollerCount = 1;
303 writePollerCount = 1;
304 if (mode == Mode.VTHREAD_POLLERS) {
305 masterPoller = DEFAULT_POLLER_GROUP.get().masterPoller();
306 } else {
307 masterPoller = null;
308 }
309 }
310
311 Executor executor = null;
312 if (mode == Mode.VTHREAD_POLLERS) {
313 String namePrefix;
314 if (scheduler == DEFAULT_SCHEDULER) {
315 namePrefix = "SubPoller-";
316 } else {
317 namePrefix = Objects.toIdentityString(scheduler) + "-SubPoller-";
318 }
319 @SuppressWarnings("restricted")
320 ThreadFactory factory = Thread.ofVirtual()
321 .scheduler(scheduler)
322 .inheritInheritableThreadLocals(false)
323 .name(namePrefix, 0)
324 .uncaughtExceptionHandler((_, e) -> e.printStackTrace())
325 .factory();
326 executor = Executors.newThreadPerTaskExecutor(factory);
327 }
328
329 // read pollers (or sub-pollers)
330 Poller[] readPollers = new Poller[readPollerCount];
331 for (int i = 0; i < readPollerCount; i++) {
332 readPollers[i] = PROVIDER.readPoller(mode == Mode.VTHREAD_POLLERS);
333 }
334
335 // write pollers (or sub-pollers)
336 Poller[] writePollers = new Poller[writePollerCount];
337 for (int i = 0; i < writePollerCount; i++) {
338 writePollers[i] = PROVIDER.writePoller(mode == Mode.VTHREAD_POLLERS);
339 }
340
341 this.scheduler = scheduler;
342 this.masterPoller = masterPoller;
343 this.readPollers = readPollers;
344 this.writePollers = writePollers;
345 this.executor = executor;
346 }
347
348 static PollerGroup create(Executor scheduler) {
349 try {
350 return new PollerGroup(scheduler).start();
351 } catch (IOException ioe) {
352 throw new UncheckedIOException(ioe);
353 }
354 }
355
356 static PollerGroup create() {
357 return create(DEFAULT_SCHEDULER);
358 }
359
360 /**
361 * Start poller threads.
362 */
363 private PollerGroup start() {
364 if (POLLER_MODE.get() == Mode.VTHREAD_POLLERS) {
365 if (scheduler == DEFAULT_SCHEDULER) {
366 startPlatformThread("Master-Poller", masterPoller::pollerLoop);
367 }
368 Arrays.stream(readPollers).forEach(p -> {
369 executor.execute(() -> p.subPollerLoop(masterPoller));
370 });
371 Arrays.stream(writePollers).forEach(p -> {
372 executor.execute(() -> p.subPollerLoop(masterPoller));
373 });
374 } else {
375 // Mode.SYSTEM_THREADS
376 Arrays.stream(readPollers).forEach(p -> {
377 startPlatformThread("Read-Poller", p::pollerLoop);
378 });
379 Arrays.stream(writePollers).forEach(p -> {
380 startPlatformThread("Write-Poller", p::pollerLoop);
381 });
382 }
383 return this;
384 }
385
386 Poller masterPoller() {
387 return masterPoller;
388 }
389
390 List<Poller> readPollers() {
391 return List.of(readPollers);
392 }
393
394 List<Poller> writePollers() {
395 return List.of(writePollers);
396 }
397
398 /**
399 * Returns the read poller for the given file descriptor.
400 */
401 Poller readPoller(int fdVal) {
402 int index = PROVIDER.fdValToIndex(fdVal, readPollers.length);
403 return readPollers[index];
404 }
405
406 /**
407 * Returns the write poller for the given file descriptor.
408 */
409 Poller writePoller(int fdVal) {
410 int index = PROVIDER.fdValToIndex(fdVal, writePollers.length);
411 return writePollers[index];
412 }
413
414 /**
415 * Reads the given property name to get the poller count. If the property is
416 * set then the value must be a power of 2. Returns 1 if the property is not
417 * set.
418 * @throws IllegalArgumentException if the property is set to a value that
419 * is not a power of 2.
420 */
421 private static int pollerCount(String propName, int defaultCount) {
422 String s = System.getProperty(propName);
423 int count = (s != null) ? Integer.parseInt(s) : defaultCount;
424
425 // check power of 2
426 if (count != Integer.highestOneBit(count)) {
427 String msg = propName + " is set to a value that is not a power of 2";
428 throw new IllegalArgumentException(msg);
429 }
430 return count;
431 }
432
433 /**
434 * Starts a platform thread to run the given task.
435 */
436 private void startPlatformThread(String name, Runnable task) {
437 try {
438 Thread thread = InnocuousThread.newSystemThread(name, task);
439 thread.setDaemon(true);
440 thread.setUncaughtExceptionHandler((t, e) -> e.printStackTrace());
441 thread.start();
442 } catch (Exception e) {
443 throw new InternalError(e);
444 }
445 }
446
447 /**
448 * Returns the PollerGroup that the given thread uses to poll file descriptors.
449 */
450 static PollerGroup groupFor(Thread thread) {
451 if (POLLER_MODE.get() == Mode.SYSTEM_THREADS) {
452 return DEFAULT_POLLER_GROUP.get();
453 }
454 Executor scheduler;
455 if (thread.isVirtual()) {
456 scheduler = JLA.virtualThreadScheduler(thread);
457 } else {
458 scheduler = DEFAULT_SCHEDULER;
459 }
460 return POLLER_GROUPS.computeIfAbsent(scheduler, _ -> PollerGroup.create(scheduler));
461 }
462 }
463
464 /**
465 * Returns the poller mode.
466 */
467 private static Mode pollerMode() {
468 String s = System.getProperty("jdk.pollerMode");
469 if (s != null) {
470 if (s.equalsIgnoreCase(Mode.SYSTEM_THREADS.name()) || s.equals("1")) {
471 return Mode.SYSTEM_THREADS;
472 } else if (s.equalsIgnoreCase(Mode.VTHREAD_POLLERS.name()) || s.equals("2")) {
473 return Mode.VTHREAD_POLLERS;
474 } else {
475 throw new RuntimeException("Can't parse '" + s + "' as polling mode");
476 }
477 } else {
478 return PROVIDER.defaultPollerMode();
479 }
480 }
481
482 /**
483 * Return the master poller or null if there is no master poller.
484 */
485 public static Poller masterPoller() {
486 return DEFAULT_POLLER_GROUP.get().masterPoller();
487 }
488
489 /**
490 * Return the list of read pollers.
491 */
492 public static List<Poller> readPollers() {
493 return DEFAULT_POLLER_GROUP.get().readPollers();
494 }
495
496 /**
497 * Return the list of write pollers.
498 */
499 public static List<Poller> writePollers() {
500 return DEFAULT_POLLER_GROUP.get().writePollers();
501 }
502 }
|