Class BlockingQueueMonitorNotificationService<T>
- java.lang.Object
-
- org.epics.ca.impl.monitor.blockingqueue.BlockingQueueMonitorNotificationService<T>
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.util.function.Supplier<T>,MonitorNotificationService<T>
@ThreadSafe public class BlockingQueueMonitorNotificationService<T> extends java.lang.Object implements MonitorNotificationService<T>, java.util.function.Supplier<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Brings this service to a state where it has disposed of its resources.Tget()voidinit()Brings this service to a state where it is ready to process new publication requests.booleanpublish(java.nio.ByteBuffer dataBuffer, TypeSupports.TypeSupport<T> typeSupport, int dataCount)Publishes a new value to a monitor's subscriber using a value that must first be deserialized from the supplied data buffer.booleanpublish(T value)Publishes a new value to a monitor's subscriber (which this library models as a Java Consumer) using the value that is directly supplied.
-
-
-
Method Detail
-
publish
public boolean publish(java.nio.ByteBuffer dataBuffer, TypeSupports.TypeSupport<T> typeSupport, int dataCount)Publishes a new value to a monitor's subscriber using a value that must first be deserialized from the supplied data buffer. This method places the responsibility of value deserialization on the service implementor. This provides the extra flexibility to reuse data structures and to avoid the cost of object creation.- Specified by:
publishin interfaceMonitorNotificationService<T>- Parameters:
dataBuffer- the byte buffer containing the new value (which must first be deserialized).typeSupport- reference to an object which has the capability of deserializing the information in the byte buffer.dataCount- the number of items in the buffer to be deserialized.- Returns:
- true when the new value was accepted without any loss of data; false if the oldest value in the notification buffer was discarded.
- Throws:
java.lang.NullPointerException- if the passed value was null.- Implementation Note:
- This implementation does not accept null as a valid publication value.
-
publish
public boolean publish(T value)
Publishes a new value to a monitor's subscriber (which this library models as a Java Consumer) using the value that is directly supplied. The new value will be published to the Consumer on one or more notification threads. Where the subscriber is not immediately able to process it (eg the previous call to the Consumer is blocked) the value may optionally be buffered. If the value notification buffer becomes full the oldest value in the buffer is thrown away.- Specified by:
publishin interfaceMonitorNotificationService<T>- Parameters:
value- the new value.- Returns:
- true when the new value was accepted without any loss of data; false if the oldest value in the notification buffer was discarded.
- Throws:
java.lang.NullPointerException- if the passed value was null.- Implementation Note:
- This implementation does not accept null as a publication value.
-
get
public T get()
- Specified by:
getin interfacejava.util.function.Supplier<T>- Implementation Note:
- This implementation returns the oldest value from the notification queue.
-
init
public void init()
Brings this service to a state where it is ready to process new publication requests.The implementation here does not need to do anything since the service leverages off a shared ThreadPoolExecutor whose lifecycle is managed outside the scope of this object's lifetime.
- Specified by:
initin interfaceMonitorNotificationService<T>
-
close
public void close()
Brings this service to a state where it has disposed of its resources. Threads that were created within the service are guaranteed to be destroyed.The implementation here does not need to do anything since the service leverages off a shared ThreadPoolExecutor whose lifecycle is managed outside the scope of this object's lifetime.
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceMonitorNotificationService<T>
-
-