client泛型优化
This commit is contained in:
@@ -15,6 +15,7 @@ import org.redkale.net.*;
|
|||||||
* 详情见: https://redkale.org
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
|
*
|
||||||
* @since 2.7.0
|
* @since 2.7.0
|
||||||
*/
|
*/
|
||||||
public class ClientAddress implements java.io.Serializable {
|
public class ClientAddress implements java.io.Serializable {
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import org.redkale.net.*;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
|
*
|
||||||
|
* @since 2.3.0
|
||||||
|
*
|
||||||
* @param <T> 泛型
|
* @param <T> 泛型
|
||||||
*/
|
*/
|
||||||
public class ClientFuture<T> extends CompletableFuture<T> implements Runnable {
|
public class ClientFuture<T> extends CompletableFuture<T> implements Runnable {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import org.redkale.net.AsyncIOThread;
|
|||||||
import org.redkale.util.ObjectPool;
|
import org.redkale.util.ObjectPool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端版的IO线程类
|
* 客户端IO读线程
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* 详情见: https://redkale.org
|
* 详情见: https://redkale.org
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
package org.redkale.net.client;
|
package org.redkale.net.client;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import org.redkale.net.WorkThread;
|
import org.redkale.net.WorkThread;
|
||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ import org.redkale.util.*;
|
|||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
*/
|
*/
|
||||||
public abstract class ClientRequest implements BiConsumer<ClientConnection, ByteArray> {
|
public abstract class ClientRequest {
|
||||||
|
|
||||||
protected long createTime = System.currentTimeMillis();
|
protected long createTime = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -27,8 +26,7 @@ public abstract class ClientRequest implements BiConsumer<ClientConnection, Byte
|
|||||||
|
|
||||||
protected String traceid;
|
protected String traceid;
|
||||||
|
|
||||||
@Override
|
public abstract void writeTo(ClientConnection conn, ByteArray array);
|
||||||
public abstract void accept(ClientConnection conn, ByteArray array);
|
|
||||||
|
|
||||||
public Serializable getRequestid() {
|
public Serializable getRequestid() {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -8,8 +8,14 @@ package org.redkale.net.client;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
|
*
|
||||||
|
* @since 2.3.0
|
||||||
|
*
|
||||||
* @param <P> message
|
* @param <P> message
|
||||||
*/
|
*/
|
||||||
public class ClientResponse<P> {
|
public class ClientResponse<P> {
|
||||||
|
|||||||
@@ -13,8 +13,14 @@ import org.redkale.net.AsyncIOThread;
|
|||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 客户端IO写线程
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
|
*
|
||||||
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
public class ClientWriteIOThread extends AsyncIOThread {
|
public class ClientWriteIOThread extends AsyncIOThread {
|
||||||
|
|
||||||
@@ -115,7 +121,7 @@ public class ClientWriteIOThread extends AsyncIOThread {
|
|||||||
for (ClientFuture en : list) {
|
for (ClientFuture en : list) {
|
||||||
++i;
|
++i;
|
||||||
ClientRequest request = en.request;
|
ClientRequest request = en.request;
|
||||||
request.accept(conn, writeArray);
|
request.writeTo(conn, writeArray);
|
||||||
if (!request.isCompleted()) {
|
if (!request.isCompleted()) {
|
||||||
conn.pauseWriting.set(true);
|
conn.pauseWriting.set(true);
|
||||||
conn.pauseRequests.addAll(list.subList(i, list.size()));
|
conn.pauseRequests.addAll(list.subList(i, list.size()));
|
||||||
|
|||||||
Reference in New Issue
Block a user