private static <T> QueueCollector<T> createQueue(int maxSize) { return new QueueCollector<>(maxSize); }
/** * Creates a new group. */ public ReadMap() { super(new DesiredRateExpressionListImpl<Object>(), new MapOfReadFunction<T>(new QueueCollector<MapUpdate<T>>(1000)), "map"); }
/** * Creates a new group. */ public WriteMap() { super(new WriteExpressionListImpl<Object>(), new MapOfWriteFunction<T>(new QueueCollector<MapUpdate<T>>(1000)), "map"); }
/** * Returns up to maxValues new values generated by the expression source rate. * * @param <T> type being read * @param expression source rate expression * @param maxValues maximum number of values to send with each notification * @return a new expression */ public static <T> DesiredRateExpression<List<T>> newValuesOf(SourceRateExpression<T> expression, int maxValues) { return new DesiredRateExpressionImpl<List<T>>(expression, new QueueCollector<T>(maxValues), expression.getName()); }
PVWriterDirector(PVWriterImpl<T> pvWriter, WriteFunction<T> writeFunction, DataSource dataSource, ScheduledExecutorService writeExecutor, Executor notificationExecutor, ScheduledExecutorService scannerExecutor, Duration writeTimeout, String writeTimeoutMessage, ExceptionHandler exceptionHandler) { this.pvRef = new WeakReference<>(pvWriter); this.writeFunction = writeFunction; this.dataSource = dataSource; this.writeExecutor = writeExecutor; this.notificationExecutor = notificationExecutor; this.scannerExecutor = scannerExecutor; this.timeout = writeTimeout; this.timeoutMessage = writeTimeoutMessage; if (exceptionHandler == null) { writeExceptionCollector = new QueueCollector<>(1); } else { writeExceptionCollector = new LastExceptionCollector(1, exceptionHandler); } }
/** * Creates a new notifier. The new notifier will notifier the given pv * with new values calculated by the function, and will use onThread to * perform the notifications. * <p> * After construction, one MUST set the pvRecipe, so that the * dataSource is appropriately closed. * * @param pv the pv on which to notify * @param function the function used to calculate new values * @param notificationExecutor the thread switching mechanism */ PVDirector(PVReaderImpl<T> pv, ReadFunction<T> function, ScheduledExecutorService scannerExecutor, Executor notificationExecutor, DataSource dataSource, ExceptionHandler exceptionHandler) { this.pvReaderRef = new WeakReference<>(pv); this.readFunction = function; this.notificationExecutor = notificationExecutor; this.scannerExecutor = scannerExecutor; this.dataSource = dataSource; if (exceptionHandler == null) { readExceptionCollector = new QueueCollector<>(1); } else { readExceptionCollector = new LastExceptionCollector(1, exceptionHandler); } }