public final class SerialComCompletionDispatcher extends Object
Represents Proactor in our IO design pattern.
An application may register data listener only, event listener only or both listeners. A single dedicated looper handles both the listeners. We first check if a looper exist for given handle or not. If it does not exist we create and start looper thread which loops over data or event as specified by application. If it exist, we start data or event looper thread as specified by application.
An application can have multiple handles for the same port (if there is no exclusive owner of port).
1. A handle can have only one looper for delivering data and line events.| Constructor and Description |
|---|
SerialComCompletionDispatcher(SerialComPortJNIBridge mComPortJNIBridge,
TreeMap<Long,SerialComPortHandleInfo> portHandleInfo)
Allocates a new SerialComCompletionDispatcher object.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
destroyDataLooper(long handle,
SerialComPortHandleInfo handleInfo,
ISerialComDataListener dataListener)
Check if we have handler corresponding to this listener and take actions accordingly.
|
boolean |
destroyEventLooper(long handle,
SerialComPortHandleInfo handleInfo,
ISerialComEventListener eventListener)
Check if we have handler corresponding to this listener and take actions accordingly.
|
boolean |
pauseListeningEvents(ISerialComEventListener listener)
Check if we have handler corresponding to this listener and take actions accordingly.
|
boolean |
resumeListeningEvents(ISerialComEventListener listener)
Check if we have handler corresponding to this listener and take actions accordingly.
|
boolean |
setUpDataLooper(long handle,
SerialComPortHandleInfo mHandleInfo,
ISerialComDataListener dataListener)
This method creates data looper thread and initialize subsystem for data event passing.
|
boolean |
setUpEventLooper(long handle,
SerialComPortHandleInfo mHandleInfo,
ISerialComEventListener eventListener)
This method creates event looper thread and initialize subsystem for line event passing.
|
public SerialComCompletionDispatcher(SerialComPortJNIBridge mComPortJNIBridge, TreeMap<Long,SerialComPortHandleInfo> portHandleInfo)
Allocates a new SerialComCompletionDispatcher object.
mComPortJNIBridge - interface used to invoke appropriate native functionportHandleInfo - reference to portHandleInfo object to get/set information about handle/portpublic boolean setUpDataLooper(long handle,
SerialComPortHandleInfo mHandleInfo,
ISerialComDataListener dataListener)
throws com.serialpundit.core.SerialComException
This method creates data looper thread and initialize subsystem for data event passing.
handle - handle of the opened port for which data looper need to be set up.mHandleInfo - Reference to SerialComPortHandleInfo object associated with given handle.dataListener - listener for which looper has to be set up.com.serialpundit.core.SerialComException - if not able to complete requested operation.public boolean destroyDataLooper(long handle,
SerialComPortHandleInfo handleInfo,
ISerialComDataListener dataListener)
throws com.serialpundit.core.SerialComException
Check if we have handler corresponding to this listener and take actions accordingly.
handle - handle of the serial port for which this data listener was registered.handleInfo - global information object about this handle.dataListener - listener for which looper has to be removed.com.serialpundit.core.SerialComException - if not able to complete requested operation.public boolean setUpEventLooper(long handle,
SerialComPortHandleInfo mHandleInfo,
ISerialComEventListener eventListener)
throws com.serialpundit.core.SerialComException
This method creates event looper thread and initialize subsystem for line event passing.
handle - handle of the opened port for which event looper need to be set up.mHandleInfo - Reference to SerialComPortHandleInfo object associated with given handle.eventListener - listener for which looper has to be set up.com.serialpundit.core.SerialComException - if an error occurs.public boolean destroyEventLooper(long handle,
SerialComPortHandleInfo handleInfo,
ISerialComEventListener eventListener)
throws com.serialpundit.core.SerialComException
Check if we have handler corresponding to this listener and take actions accordingly.
handle - handle of the serial port for which this event listener was registered.handleInfo - global information object about this handle.eventListener - listener for which looper has to be removed.com.serialpundit.core.SerialComException - if not able to complete requested operation.public boolean pauseListeningEvents(ISerialComEventListener listener) throws com.serialpundit.core.SerialComException
Check if we have handler corresponding to this listener and take actions accordingly.
listener - listener for which event has to be paused.com.serialpundit.core.SerialComException - if not able to complete requested operation.public boolean resumeListeningEvents(ISerialComEventListener listener) throws com.serialpundit.core.SerialComException
Check if we have handler corresponding to this listener and take actions accordingly.
listener - for which events sending should be resumed.com.serialpundit.core.SerialComException - if not able to complete requested operation.Copyright © 2017. All rights reserved.