Java Code Examples for reactor.core.Scannable#Attr
The following examples show how to use
reactor.core.Scannable#Attr .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluxSubscribeOnValue.java From reactor-core with Apache License 2.0 | 6 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Attr.CANCELLED) { return future == OperatorDisposables.DISPOSED; } if (key == Attr.TERMINATED) { return future == FINISHED; } if (key == Attr.BUFFERED) { return 1; } if (key == Attr.RUN_ON) return scheduler; return InnerProducer.super.scanUnsafe(key); }
Example 2
Source File: Schedulers.java From reactor-core with Apache License 2.0 | 6 votes |
/** * Scan an {@link Executor} or {@link ExecutorService}, recognizing several special * implementations. Unwraps some decorating schedulers, recognizes {@link Scannable} * schedulers and delegates to their {@link Scannable#scanUnsafe(Scannable.Attr)} * method, introspects {@link ThreadPoolExecutor} instances. * <p> * If no data can be extracted, defaults to the provided {@code orElse} * {@link Scannable#scanUnsafe(Scannable.Attr) scanUnsafe}. * * @param executor the executor to introspect in a best effort manner. * @param key the key to scan for. CAPACITY and BUFFERED mainly. * @return an equivalent of {@link Scannable#scanUnsafe(Scannable.Attr)} but that can * also work on some implementations of {@link Executor} */ @Nullable static final Object scanExecutor(Executor executor, Scannable.Attr key) { if (executor instanceof DelegateServiceScheduler.UnsupportedScheduledExecutorService) { executor = ((DelegateServiceScheduler.UnsupportedScheduledExecutorService) executor).get(); } if (executor instanceof Scannable) { return ((Scannable) executor).scanUnsafe(key); } if (executor instanceof ExecutorService) { ExecutorService service = (ExecutorService) executor; if (key == Scannable.Attr.TERMINATED) return service.isTerminated(); if (key == Scannable.Attr.CANCELLED) return service.isShutdown(); } if (executor instanceof ThreadPoolExecutor) { final ThreadPoolExecutor poolExecutor = (ThreadPoolExecutor) executor; if (key == Scannable.Attr.CAPACITY) return poolExecutor.getMaximumPoolSize(); if (key == Scannable.Attr.BUFFERED) return ((Long) (poolExecutor.getTaskCount() - poolExecutor.getCompletedTaskCount())).intValue(); if (key == Scannable.Attr.LARGE_BUFFERED) return poolExecutor.getTaskCount() - poolExecutor.getCompletedTaskCount(); } return null; }
Example 3
Source File: FluxReplay.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Attr.PREFETCH) return getPrefetch(); if (key == Attr.PARENT) return source; if (key == Attr.RUN_ON) return scheduler; return null; }
Example 4
Source File: MonoFromPublisher.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Scannable.Attr.PARENT) { return source; } return null; }
Example 5
Source File: ParallelSource.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Attr.PARENT) return source; if (key == Attr.PREFETCH) return getPrefetch(); return null; }
Example 6
Source File: FluxSourceFuseable.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Scannable.Attr.PREFETCH) return getPrefetch(); if (key == Scannable.Attr.PARENT) return source; return null; }
Example 7
Source File: ParallelReduceSeed.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Attr.PARENT) return source; if (key == Attr.PREFETCH) return getPrefetch(); return null; }
Example 8
Source File: MonoIgnorePublisher.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Scannable.Attr.PARENT) { return source; } return null; }
Example 9
Source File: ConnectableFluxHide.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Scannable.Attr.PARENT) return source; if (key == Scannable.Attr.PREFETCH) return getPrefetch(); return null; }
Example 10
Source File: InternalConnectableFluxOperator.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @Nullable public Object scanUnsafe(Scannable.Attr key) { if (key == Scannable.Attr.PREFETCH) return getPrefetch(); if (key == Scannable.Attr.PARENT) return source; return null; }
Example 11
Source File: MonoSubscribeOnCallable.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public Object scanUnsafe(Scannable.Attr key) { if (key == Scannable.Attr.RUN_ON) return scheduler; return null; }