Rename the 'b2' package to 'api'

This commit is contained in:
Chris Vest 2020-11-17 15:38:11 +01:00
parent 0ad7f648ae
commit 3efa93841e
25 changed files with 46 additions and 49 deletions

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.nio.ByteOrder;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
/**
* Methods for accessing and controlling the internals of an allocator.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
/**
* This interface is just the primitive data accessor methods that {@link Buf} exposes.

View File

@ -12,7 +12,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import io.netty.util.ByteProcessor;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -27,7 +27,8 @@ final class CompositeBuf extends RcSupport<Buf, CompositeBuf> implements Buf {
* non-composite copy of the buffer.
*/
private static final int MAX_CAPACITY = Integer.MAX_VALUE - 8;
private static final Drop<CompositeBuf> COMPOSITE_DROP = new Drop<CompositeBuf>() {
private static final Drop<CompositeBuf>
COMPOSITE_DROP = new Drop<CompositeBuf>() {
@Override
public void drop(CompositeBuf obj) {
for (Buf buf : obj.bufs) {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.util.function.Consumer;

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.lang.ref.Cleaner;
import static io.netty.buffer.b2.Statics.NO_OP_DROP;
import static io.netty.buffer.api.Statics.NO_OP_DROP;
class ManagedAllocator implements Allocator, AllocatorControl {
private final MemoryManager manager;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import jdk.incubator.foreign.MemorySegment;

View File

@ -13,8 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import io.netty.buffer.api.MemSegBuf.RecoverableMemory;
import jdk.incubator.foreign.MemorySegment;
import java.lang.ref.Cleaner;
@ -72,7 +73,7 @@ public interface MemoryManager {
@Override
public Buf recoverMemory(Object recoverableMemory, Drop<Buf> drop) {
var recovery = (MemSegBuf.RecoverableMemory) recoverableMemory;
var recovery = (RecoverableMemory) recoverableMemory;
return recovery.recover(convert(drop));
}

View File

@ -13,15 +13,15 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.lang.invoke.VarHandle;
import java.lang.ref.Cleaner.Cleanable;
import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicBoolean;
import static io.netty.buffer.b2.Statics.CLEANER;
import static io.netty.buffer.b2.Statics.findVarHandle;
import static io.netty.buffer.api.Statics.CLEANER;
import static io.netty.buffer.api.Statics.findVarHandle;
import static java.lang.invoke.MethodHandles.lookup;
class NativeMemoryCleanerDrop implements Drop<Buf> {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
/**
* This interface encapsulates the ownership of an {@link Rc}, and exposes a method that may be used to transfer this

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
/**
* An Rc is a reference counted, thread-confined, resource of sorts. Because these resources are thread-confined, the

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
public abstract class RcSupport<I extends Rc<I>, T extends RcSupport<I, T>> implements Rc<I> {
private int acquires; // Closed if negative.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
/**
* Thrown when resource disposal fails while closing a resource pool.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.util.ArrayDeque;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
/**
* A Send object is a temporary holder of an {@link Rc}, used for transferring the ownership of the Rc from one thread

View File

@ -13,14 +13,14 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.lang.invoke.VarHandle;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import static io.netty.buffer.b2.Statics.NO_OP_DROP;
import static io.netty.buffer.api.Statics.NO_OP_DROP;
import static java.lang.invoke.MethodHandles.lookup;
class SizeClassedMemoryPool implements Allocator, AllocatorControl, Drop<Buf> {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.VarHandle;

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.lang.invoke.VarHandle;
import static io.netty.buffer.b2.Statics.findVarHandle;
import static io.netty.buffer.api.Statics.findVarHandle;
import static java.lang.invoke.MethodHandles.lookup;
class TransferSend<I extends Rc<I>, T extends Rc<I>> implements Send<I> {

View File

@ -17,4 +17,4 @@
/**
* Experimental {@code Buf} implementation, based on MemorySegment, as a potential alternative to {@code ByteBuf}.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;

View File

@ -13,8 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import io.netty.buffer.api.Fixture.Properties;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
@ -40,12 +41,6 @@ import java.util.function.Function;
import java.util.stream.Stream;
import java.util.stream.Stream.Builder;
import static io.netty.buffer.b2.Fixture.Properties.CLEANER;
import static io.netty.buffer.b2.Fixture.Properties.COMPOSITE;
import static io.netty.buffer.b2.Fixture.Properties.DIRECT;
import static io.netty.buffer.b2.Fixture.Properties.HEAP;
import static io.netty.buffer.b2.Fixture.Properties.POOLED;
import static io.netty.buffer.b2.Fixture.Properties.SLICE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@ -90,12 +85,12 @@ public class BufTest {
return Arrays.stream(fxs);
}
List<Fixture> initFixtures = List.of(
new Fixture("heap", Allocator::heap, HEAP),
new Fixture("direct", Allocator::direct, DIRECT),
new Fixture("directWithCleaner", Allocator::directWithCleaner, DIRECT, CLEANER),
new Fixture("pooledHeap", Allocator::pooledHeap, POOLED, HEAP),
new Fixture("pooledDirect", Allocator::pooledDirect, POOLED, DIRECT),
new Fixture("pooledDirectWithCleaner", Allocator::pooledDirectWithCleaner, POOLED, DIRECT, CLEANER));
new Fixture("heap", Allocator::heap, Properties.HEAP),
new Fixture("direct", Allocator::direct, Properties.DIRECT),
new Fixture("directWithCleaner", Allocator::directWithCleaner, Properties.DIRECT, Properties.CLEANER),
new Fixture("pooledHeap", Allocator::pooledHeap, Properties.POOLED, Properties.HEAP),
new Fixture("pooledDirect", Allocator::pooledDirect, Properties.POOLED, Properties.DIRECT),
new Fixture("pooledDirectWithCleaner", Allocator::pooledDirectWithCleaner, Properties.POOLED, Properties.DIRECT, Properties.CLEANER));
Builder<Fixture> builder = Stream.builder();
initFixtures.forEach(builder);
@ -121,7 +116,7 @@ public class BufTest {
b.close();
}
};
}, COMPOSITE));
}, Properties.COMPOSITE));
}
}
@ -144,7 +139,7 @@ public class BufTest {
alloc.close();
}
};
}, COMPOSITE));
}, Properties.COMPOSITE));
for (Fixture fixture : initFixtures) {
builder.add(new Fixture(fixture + ".ensureWritable", () -> {
@ -184,7 +179,7 @@ public class BufTest {
allocator.close();
}
};
}, COMPOSITE));
}, Properties.COMPOSITE));
}
return builder.build().flatMap(f -> {
@ -206,7 +201,7 @@ public class BufTest {
allocatorBase.close();
}
};
}, SLICE));
}, Properties.SLICE));
andSlices.add(new Fixture(f + ".slice(1, capacity() - 2)", () -> {
var allocatorBase = f.get();
return new Allocator() {
@ -222,7 +217,7 @@ public class BufTest {
allocatorBase.close();
}
};
}, SLICE));
}, Properties.SLICE));
return andSlices.build();
});
}

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import java.util.Arrays;
import java.util.EnumSet;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.buffer.b2;
package io.netty.buffer.api;
import org.junit.Test;