This commit is contained in:
@@ -15,7 +15,6 @@ import java.time.ZoneId;
|
||||
import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.convert.*;
|
||||
@@ -154,10 +153,6 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
|
||||
private final HttpRender onlyoneHttpRender;
|
||||
|
||||
public static ObjectPool<Response> createPool(AtomicLong creatCounter, AtomicLong cycleCounter, int max, Creator<Response> creator) {
|
||||
return ObjectPool.createSafePool(creatCounter, cycleCounter, max, creator, (x) -> ((HttpResponse) x).prepare(), (x) -> ((HttpResponse) x).recycle());
|
||||
}
|
||||
|
||||
public HttpResponse(HttpContext context, HttpRequest request, ObjectPool<Response> responsePool, HttpResponseConfig config) {
|
||||
super(context, request, responsePool);
|
||||
this.plainContentType = config == null || config.plainContentType == null || config.plainContentType.isEmpty() ? "text/plain; charset=utf-8" : config.plainContentType;
|
||||
|
||||
@@ -469,7 +469,7 @@ public class HttpServer extends Server<String, HttpContext, HttpRequest, HttpRes
|
||||
|
||||
@Override
|
||||
protected ObjectPool<Response> createResponsePool(AtomicLong createCounter, AtomicLong cycleCounter, int responsePoolSize) {
|
||||
ObjectPool<Response> pool = HttpResponse.createPool(createCounter, cycleCounter, responsePoolSize, null);
|
||||
ObjectPool<Response> pool = ObjectPool.createSafePool(createCounter, cycleCounter, responsePoolSize,(Creator)null, (x) ->((HttpResponse)x).prepare(),(x) -> ((HttpResponse)x).recycle());
|
||||
pool.setCreator((Object... params) -> new HttpResponse(this.context, new HttpRequest(this.context), pool, this.respConfig));
|
||||
return pool;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package org.redkale.net.sncp;
|
||||
|
||||
import static org.redkale.net.sncp.SncpRequest.HEADER_SIZE;
|
||||
import java.nio.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import org.redkale.convert.bson.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.util.*;
|
||||
@@ -29,10 +28,6 @@ public class SncpResponse extends Response<SncpContext, SncpRequest> {
|
||||
|
||||
public static final int RETCODE_THROWEXCEPTION = (1 << 4); //内部异常
|
||||
|
||||
public static ObjectPool<Response> createPool(AtomicLong creatCounter, AtomicLong cycleCounter, int max, Creator<Response> creator) {
|
||||
return ObjectPool.createSafePool(creatCounter, cycleCounter, max, creator, (x) -> ((SncpResponse) x).prepare(), (x) -> ((SncpResponse) x).recycle());
|
||||
}
|
||||
|
||||
private final byte[] addrBytes;
|
||||
|
||||
private final int addrPort;
|
||||
@@ -52,6 +47,16 @@ public class SncpResponse extends Response<SncpContext, SncpRequest> {
|
||||
if (this.addrBytes.length != 4) throw new RuntimeException("SNCP serverAddress only support IPv4");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepare() {
|
||||
super.prepare();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean recycle() {
|
||||
return super.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void offerBuffer(ByteBuffer... buffers) {
|
||||
super.offerBuffer(buffers);
|
||||
|
||||
@@ -145,7 +145,7 @@ public class SncpServer extends Server<DLong, SncpContext, SncpRequest, SncpResp
|
||||
|
||||
@Override
|
||||
protected ObjectPool<Response> createResponsePool(AtomicLong createCounter, AtomicLong cycleCounter, int responsePoolSize) {
|
||||
ObjectPool<Response> pool = SncpResponse.createPool(createCounter, cycleCounter, responsePoolSize, null);
|
||||
ObjectPool<Response> pool = ObjectPool.createSafePool(createCounter, cycleCounter, responsePoolSize, (Creator) null, (x) -> ((SncpResponse) x).prepare(), (x) -> ((SncpResponse) x).recycle());
|
||||
pool.setCreator((Object... params) -> new SncpResponse(this.context, new SncpRequest(this.context), pool));
|
||||
return pool;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user