public class AsyncExecutor extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
AsyncExecutor.ReadableNotify
有数据到达时的外部通知接口
|
| 构造器和说明 |
|---|
AsyncExecutor() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
closeExecutor()
关闭线程池
|
void |
createExecutor(ISerialPort serialPort)
创建线程池
|
boolean |
isReadable()
是否有接收数据到达
|
List<byte[]> |
readRecvList()
异步接收数据的模式2:多程模式
多线程中,setReadableNotify(readableNotify)后,外部线程等待readableNotify的wait()消息,然后来读取缓存中的数据
本异步线程在有数据到达的时候,会发出一个notify,来触发readableNotify上的wait后,可以用readRecvList进行读取数据
|
void |
setReadableNotify(AsyncExecutor.ReadableNotify readableNotify)
数据抵达时的外部通知接口
实现多线程之间的wait和notify
|
List<byte[]> |
waitReadable(long timeout)
异步接收数据的模式1:单线程模式
单线程中,该单循环waitWriteable(),来读取缓存中的数据
本异步线程在有数据到达的时候,会发出一个notify,来触发waitWriteable()往下一步执行
|
void |
waitWriteable(byte[] data)
异步发送数据
|
public void setReadableNotify(AsyncExecutor.ReadableNotify readableNotify)
readableNotify - 通知接口public void closeExecutor()
public void createExecutor(ISerialPort serialPort)
serialPort - public void waitWriteable(byte[] data)
data - 等待发送的数据public boolean isReadable()
public List<byte[]> waitReadable(long timeout)
timeout - 等待超时public List<byte[]> readRecvList()
Copyright © 2024. All rights reserved.