Skip to content

Commit

Permalink
Rename SharedByteArrayParams to FlexByteArrayPoolParams
Browse files Browse the repository at this point in the history
  • Loading branch information
tyronen committed Jul 20, 2015
1 parent 0417f03 commit 524e8b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
/**
* Provides pool parameters ({@link PoolParams}) for {@link SharedByteArray}
*/
public class DefaultSharedByteArrayParams {
public class DefaultFlexByteArrayPoolParams {
// the default max buffer size we'll use
public static final int DEFAULT_MAX_BYTE_ARRAY_SIZE = 4 * ByteConstants.MB;
// the min buffer size we'll use
private static final int DEFAULT_MIN_BYTE_ARRAY_SIZE = 128 * ByteConstants.KB;

private DefaultSharedByteArrayParams() {
private DefaultFlexByteArrayPoolParams() {
}

public static SparseIntArray generateBuckets(int min, int max) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public class PoolConfig {

private final PoolParams mBitmapPoolParams;
private final PoolStatsTracker mBitmapPoolStatsTracker;
private final PoolParams mFlexByteArrayPoolParams;
private final MemoryTrimmableRegistry mMemoryTrimmableRegistry;
private final PoolParams mNativeMemoryChunkPoolParams;
private final PoolStatsTracker mNativeMemoryChunkPoolStatsTracker;
private final PoolParams mSharedByteArrayParams;
private final PoolParams mSmallByteArrayPoolParams;
private final PoolStatsTracker mSmallByteArrayPoolStatsTracker;

Expand All @@ -38,6 +38,10 @@ private PoolConfig(Builder builder) {
builder.mBitmapPoolStatsTracker == null ?
NoOpPoolStatsTracker.getInstance() :
builder.mBitmapPoolStatsTracker;
mFlexByteArrayPoolParams =
builder.mFlexByteArrayPoolParams == null ?
DefaultFlexByteArrayPoolParams.get() :
builder.mFlexByteArrayPoolParams;
mMemoryTrimmableRegistry =
builder.mMemoryTrimmableRegistry == null ?
NoOpMemoryTrimmableRegistry.getInstance() :
Expand All @@ -50,10 +54,6 @@ private PoolConfig(Builder builder) {
builder.mNativeMemoryChunkPoolStatsTracker == null ?
NoOpPoolStatsTracker.getInstance() :
builder.mNativeMemoryChunkPoolStatsTracker;
mSharedByteArrayParams =
builder.mSharedByteArrayParams == null ?
DefaultSharedByteArrayParams.get() :
builder.mSharedByteArrayParams;
mSmallByteArrayPoolParams =
builder.mSmallByteArrayPoolParams == null ?
DefaultByteArrayPoolParams.get() :
Expand Down Expand Up @@ -84,8 +84,8 @@ public PoolStatsTracker getNativeMemoryChunkPoolStatsTracker() {
return mNativeMemoryChunkPoolStatsTracker;
}

public PoolParams getSharedByteArrayParams() {
return mSharedByteArrayParams;
public PoolParams getFlexByteArrayPoolParams() {
return mFlexByteArrayPoolParams;
}

public PoolParams getSmallByteArrayPoolParams() {
Expand All @@ -109,7 +109,7 @@ public static class Builder {
private MemoryTrimmableRegistry mMemoryTrimmableRegistry;
private PoolParams mNativeMemoryChunkPoolParams;
private PoolStatsTracker mNativeMemoryChunkPoolStatsTracker;
private PoolParams mSharedByteArrayParams;
private PoolParams mFlexByteArrayPoolParams;

private Builder() {
}
Expand All @@ -125,6 +125,11 @@ public Builder setBitmapPoolStatsTracker(
return this;
}

public Builder setFlexByteArrayPoolParams(PoolParams flexByteArrayPoolParams) {
mFlexByteArrayPoolParams = flexByteArrayPoolParams;
return this;
}

public Builder setSmallByteArrayPoolParams(PoolParams commonByteArrayPoolParams) {
mSmallByteArrayPoolParams = Preconditions.checkNotNull(commonByteArrayPoolParams);
return this;
Expand Down Expand Up @@ -154,11 +159,6 @@ public Builder setNativeMemoryChunkPoolStatsTracker(
return this;
}

public Builder setSharedByteArrayParams(PoolParams sharedByteArrayParams) {
mSharedByteArrayParams = sharedByteArrayParams;
return this;
}

public PoolConfig build() {
return new PoolConfig(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public SharedByteArray getSharedByteArray() {
if (mSharedByteArray == null) {
mSharedByteArray = new SharedByteArray(
mConfig.getMemoryTrimmableRegistry(),
mConfig.getSharedByteArrayParams());
mConfig.getFlexByteArrayPoolParams());
}
return mSharedByteArray;
}
Expand All @@ -92,7 +92,7 @@ public FlexByteArrayPool getFlexByteArrayPool() {
if (mFlexByteArrayPool == null) {
mFlexByteArrayPool = new FlexByteArrayPool(
mConfig.getMemoryTrimmableRegistry(),
mConfig.getSharedByteArrayParams(),
mConfig.getFlexByteArrayPoolParams(),
1);
}
return mFlexByteArrayPool;
Expand Down

0 comments on commit 524e8b8

Please sign in to comment.