Skip to content

Commit

Permalink
Javadocs cleanup / added
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Maurer committed Mar 10, 2013
1 parent 0504a44 commit 0a1bc86
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,10 @@ protected final void checkReadableBytes(int minimumReadableBytes) {
}
}

/**
* Should be called by every method that tries to access the buffers content to check
* if the buffer was released before.
*/
protected final void ensureAccessible() {
if (refCnt() == 0) {
throw new IllegalBufferAccessException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

/**
* Abstract base class for classes wants to implement {@link ReferenceCounted}.
*/
public abstract class AbstractReferenceCounted implements ReferenceCounted {

private static final AtomicIntegerFieldUpdater<AbstractReferenceCounted> refCntUpdater =
Expand Down Expand Up @@ -131,5 +134,8 @@ public final boolean release(int decrement) {
}
}

/**
* Called once {@link #refCnt()} is equals 0.
*/
protected abstract void deallocate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,8 @@ public final boolean release(int decrement) {
}
}

/**
* Called once {@link #refCnt()} is equals 0.
*/
protected abstract void deallocate();
}
14 changes: 14 additions & 0 deletions buffer/src/main/java/io/netty/buffer/Unpooled.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,32 @@ public final class Unpooled {
*/
public static final ByteBuf EMPTY_BUFFER = ALLOC.buffer(0, 0);

/**
* Creates a new {@link MessageBuf} with reasonably small initial capacity, which
* expands its capacity boundlessly on demand.
*/
public static <T> MessageBuf<T> messageBuffer() {
return new DefaultMessageBuf<T>();
}

/**
* Creates a new {@link MessageBuf} with the specified {@code initialCapacity}.
*/
public static <T> MessageBuf<T> messageBuffer(int initialCapacity) {
return new DefaultMessageBuf<T>(initialCapacity);
}

/**
* Creates a new {@link MessageBuf} with the specified {@code initialCapacity} and
* {@code maxCapacity}.
*/
public static <T> MessageBuf<T> messageBuffer(int initialCapacity, int maxCapacity) {
return new DefaultMessageBuf<T>(initialCapacity, maxCapacity);
}

/**
* Creates a new {@link MessageBuf} which wraps the given {@code queue}.
*/
public static <T> MessageBuf<T> wrappedBuffer(Queue<T> queue) {
if (queue instanceof MessageBuf) {
return (MessageBuf<T>) queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@
*/
public final class UnpooledByteBufAllocator extends AbstractByteBufAllocator {

/**
* Default instance
*/
public static final UnpooledByteBufAllocator DEFAULT =
new UnpooledByteBufAllocator(PlatformDependent.directBufferPreferred());

/**
* Create a new instance
*
* @param preferDirect {@code true} if {@link #buffer(int)} should try to allocate a direct buffer rather than
* a heap buffer
*/
public UnpooledByteBufAllocator(boolean preferDirect) {
super(preferDirect);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package io.netty.channel;

/**
* Skelton implementation of a {@link ChannelHandler}.
*/
public abstract class ChannelHandlerAdapter implements ChannelHandler {

// Not using volatile because it's used only for a sanity check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;

/**
* Utility methods for use within your {@link ChannelHandler} implementation.
*/
public final class ChannelHandlerUtil {

public static final Signal ABORT = new Signal(ChannelHandlerUtil.class.getName() + ".ABORT");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

import java.net.SocketAddress;

/**
* Skelton implementation of a {@link ChannelOperationHandler}. This implementation just forwards each method call via
* the {@link ChannelHandlerContext}.
*/
public abstract class ChannelOperationHandlerAdapter extends ChannelHandlerAdapter implements ChannelOperationHandler {

/**
Expand Down Expand Up @@ -79,6 +83,12 @@ public void deregister(ChannelHandlerContext ctx, ChannelPromise promise)
ctx.deregister(promise);
}

/**
* Calls {@link ChannelHandlerContext#read()} to forward
* to the next {@link ChannelOperationHandler} in the {@link ChannelPipeline}.
*
* Sub-classes may override this method to change behavior.
*/
@Override
public void read(ChannelHandlerContext ctx) {
ctx.read();
Expand Down

0 comments on commit 0a1bc86

Please sign in to comment.