Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 53ba97e

Browse files
authored
Merge pull request #29 from netty/renames
API Renames after feedback
2 parents 5f1f0ba + 5434fa8 commit 53ba97e

34 files changed

+1789
-1739
lines changed

src/main/java/io/netty/buffer/api/AllocatorControl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@
1717

1818
/**
1919
* Methods for accessing and controlling the internals of an allocator.
20-
* This interface is intended to be used by implementors of the {@link Allocator}, {@link Buf} and
20+
* This interface is intended to be used by implementors of the {@link BufferAllocator}, {@link Buffer} and
2121
* {@link MemoryManager} interfaces.
2222
*/
2323
public interface AllocatorControl {
2424
/**
2525
* Allocate a buffer that is not tethered to any particular {@link Drop} implementation,
2626
* and return the recoverable memory object from it.
2727
* <p>
28-
* This allows a buffer to implement {@link Buf#ensureWritable(int)} by having new memory allocated to it,
28+
* This allows a buffer to implement {@link Buffer#ensureWritable(int)} by having new memory allocated to it,
2929
* without that memory being attached to some other lifetime.
3030
*
3131
* @param originator The buffer that originated the request for an untethered memory allocated.
3232
* @param size The size of the requested memory allocation, in bytes.
3333
* @return A "recoverable memory" object that is the requested allocation.
3434
*/
35-
Object allocateUntethered(Buf originator, int size);
35+
Object allocateUntethered(Buffer originator, int size);
3636

3737
/**
3838
* Return memory to the allocator, after it has been untethered from it's lifetime.
3939
* This either happens if the memory has leaked and been re-captured, or if it is no longer in use by a buffer
40-
* through {@link Buf#ensureWritable(int)}.
40+
* through {@link Buffer#ensureWritable(int)}.
4141
*
4242
* @param memory The untethered memory to return to the allocator.
4343
*/

src/main/java/io/netty/buffer/api/Buf.java renamed to src/main/java/io/netty/buffer/api/Buffer.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616
package io.netty.buffer.api;
1717

18-
import io.netty.buffer.api.ComponentProcessor.ReadableComponentProcessor;
19-
import io.netty.buffer.api.ComponentProcessor.WritableComponentProcessor;
20-
import io.netty.buffer.api.ComponentProcessor.ReadableComponent;
21-
import io.netty.buffer.api.ComponentProcessor.WritableComponent;
22-
2318
import java.nio.ByteBuffer;
2419
import java.nio.ByteOrder;
2520

@@ -30,8 +25,9 @@
3025
*
3126
* <h3>Creating a buffer</h3>
3227
*
33-
* Buffers are created by {@linkplain Allocator allocators}, and their {@code allocate} family of methods.
34-
* A number of standard allocators exist, and ara available through static methods on the {@code Allocator} interface.
28+
* Buffers are created by {@linkplain BufferAllocator allocators}, and their {@code allocate} family of methods.
29+
* A number of standard allocators exist, and ara available through static methods on the {@code BufferAllocator}
30+
* interface.
3531
*
3632
* <h3>Life cycle and reference counting</h3>
3733
*
@@ -70,7 +66,7 @@
7066
* To send a buffer to another thread, the buffer must not have any outstanding borrows.
7167
* That is to say, all {@linkplain #acquire() acquires} must have been paired with a {@link #close()};
7268
* all {@linkplain #slice() slices} must have been closed.
73-
* And if this buffer is a constituent of a {@linkplain Allocator#compose(Deref...) composite buffer},
69+
* And if this buffer is a constituent of a {@linkplain BufferAllocator#compose(Deref...) composite buffer},
7470
* then that composite buffer must be closed.
7571
* And if this buffer is itself a composite buffer, then it must own all of its constituent buffers.
7672
* The {@link #isOwned()} method can be used on any buffer to check if it can be sent or not.
@@ -106,14 +102,14 @@
106102
* </pre>
107103
*
108104
*/
109-
public interface Buf extends Rc<Buf>, BufAccessors {
105+
public interface Buffer extends Rc<Buffer>, BufferAccessors {
110106
/**
111107
* Change the default byte order of this buffer, and return this buffer.
112108
*
113109
* @param order The new default byte order, used by accessor methods that don't use an explicit byte order.
114110
* @return This buffer instance.
115111
*/
116-
Buf order(ByteOrder order);
112+
Buffer order(ByteOrder order);
117113

118114
/**
119115
* The default byte order of this buffer.
@@ -139,11 +135,11 @@ public interface Buf extends Rc<Buf>, BufAccessors {
139135
* Set the reader offset. Make the next read happen from the given offset into the buffer.
140136
*
141137
* @param offset The reader offset to set.
142-
* @return This Buf.
138+
* @return This Buffer.
143139
* @throws IndexOutOfBoundsException if the specified {@code offset} is less than zero or greater than the current
144140
* {@link #writerOffset()}.
145141
*/
146-
Buf readerOffset(int offset);
142+
Buffer readerOffset(int offset);
147143

148144
/**
149145
* Get the current writer offset. The next write will happen at this byte offset into the byffer.
@@ -156,12 +152,12 @@ public interface Buf extends Rc<Buf>, BufAccessors {
156152
* Set the writer offset. Make the next write happen at the given offset.
157153
*
158154
* @param offset The writer offset to set.
159-
* @return This Buf.
155+
* @return This Buffer.
160156
* @throws IndexOutOfBoundsException if the specified {@code offset} is less than the current
161157
* {@link #readerOffset()} or greater than {@link #capacity()}.
162158
* @throws IllegalStateException if this buffer is {@linkplain #readOnly() read-only}.
163159
*/
164-
Buf writerOffset(int offset);
160+
Buffer writerOffset(int offset);
165161

166162
/**
167163
* Returns the number of readable bytes which is equal to {@code (writerOffset() - readerOffset())}.
@@ -183,10 +179,10 @@ default int writableBytes() {
183179
* #writerOffset()} are not modified.
184180
*
185181
* @param value The byte value to write at every position in the buffer.
186-
* @return This Buf.
182+
* @return This Buffer.
187183
* @throws IllegalStateException if this buffer is {@linkplain #readOnly() read-only}.
188184
*/
189-
Buf fill(byte value);
185+
Buffer fill(byte value);
190186

191187
/**
192188
* Give the native memory address backing this buffer, or return 0 if this buffer has no native memory address.
@@ -199,7 +195,7 @@ default int writableBytes() {
199195
*
200196
* @return this buffer.
201197
*/
202-
Buf readOnly(boolean readOnly);
198+
Buffer readOnly(boolean readOnly);
203199

204200
/**
205201
* Query if this buffer is read-only or not.
@@ -224,7 +220,7 @@ default int writableBytes() {
224220
* @return A new buffer instance, with independent {@link #readerOffset()} and {@link #writerOffset()},
225221
* that is a view of the readable region of this buffer.
226222
*/
227-
default Buf slice() {
223+
default Buffer slice() {
228224
return slice(readerOffset(), readableBytes());
229225
}
230226

@@ -243,7 +239,7 @@ default Buf slice() {
243239
* @return A new buffer instance, with independent {@link #readerOffset()} and {@link #writerOffset()},
244240
* that is a view of the given region of this buffer.
245241
*/
246-
Buf slice(int offset, int length);
242+
Buffer slice(int offset, int length);
247243

248244
/**
249245
* Copies the given length of data from this buffer into the given destination array, beginning at the given source
@@ -303,13 +299,13 @@ default Buf slice() {
303299
* @throws IndexOutOfBoundsException if the source or destination positions, or the length, are negative,
304300
* or if the resulting end positions reaches beyond the end of either this buffer or the destination array.
305301
*/
306-
void copyInto(int srcPos, Buf dest, int destPos, int length);
302+
void copyInto(int srcPos, Buffer dest, int destPos, int length);
307303

308304
/**
309305
* Resets the {@linkplain #readerOffset() read offset} and the {@linkplain #writerOffset() write offset} on this
310306
* buffer to their initial values.
311307
*/
312-
default Buf reset() {
308+
default Buffer reset() {
313309
readerOffset(0);
314310
writerOffset(0);
315311
return this;
@@ -386,8 +382,8 @@ default ByteCursor openReverseCursor() {
386382
* bytes.
387383
* The buffer must be in {@linkplain #isOwned() an owned state}, or an exception will be thrown.
388384
* If this buffer already has the necessary space, then this method returns immediately.
389-
* If this buffer does not already have the necessary space, then it will be expanded using the {@link Allocator}
390-
* the buffer was created with.
385+
* If this buffer does not already have the necessary space, then it will be expanded using the
386+
* {@link BufferAllocator} the buffer was created with.
391387
* This method is the same as calling {@link #ensureWritable(int, boolean)} where {@code allowCompaction} is
392388
* {@code false}.
393389
*
@@ -418,8 +414,8 @@ default void ensureWritable(int size) {
418414
* </li>
419415
* <li>
420416
* Regardless of the value of the {@code allowCompaction}, the implementation may make more space available
421-
* by just allocating more or larger buffers. This allocation would use the same {@link Allocator} that this
422-
* buffer was created with.
417+
* by just allocating more or larger buffers. This allocation would use the same {@link BufferAllocator}
418+
* that this buffer was created with.
423419
* </li>
424420
* <li>
425421
* If {@code allowCompaction} is {@code true}, then the implementation may choose to do a combination of
@@ -480,7 +476,7 @@ default void ensureWritable(int size) {
480476
*
481477
* @return A new buffer with independent and exclusive ownership over the read and readable bytes from this buffer.
482478
*/
483-
Buf bifurcate();
479+
Buffer bifurcate();
484480

485481
/**
486482
* Discards the read bytes, and moves the buffer contents to the beginning of the buffer.

0 commit comments

Comments
 (0)