1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel;
17
18 import static io.netty.util.internal.ObjectUtil.checkPositive;
19
20
21
22
23
24 public class FixedRecvByteBufAllocator extends DefaultMaxMessagesRecvByteBufAllocator {
25
26 private final int bufferSize;
27
28 private final class HandleImpl extends MaxMessageHandle {
29 private final int bufferSize;
30
31 HandleImpl(int bufferSize) {
32 this.bufferSize = bufferSize;
33 }
34
35 @Override
36 public int guess() {
37 return bufferSize;
38 }
39 }
40
41
42
43
44
45 public FixedRecvByteBufAllocator(int bufferSize) {
46 checkPositive(bufferSize, "bufferSize");
47 this.bufferSize = bufferSize;
48 }
49
50 @SuppressWarnings("deprecation")
51 @Override
52 public Handle newHandle() {
53 return new HandleImpl(bufferSize);
54 }
55
56 @Override
57 public FixedRecvByteBufAllocator respectMaybeMoreData(boolean respectMaybeMoreData) {
58 super.respectMaybeMoreData(respectMaybeMoreData);
59 return this;
60 }
61 }