Remove Buffer redundant strategy judgment code. (#5277)

This commit is contained in:
李文广 2020-08-09 16:21:36 +08:00 committed by GitHub
parent b0bb7cf3be
commit b8e5ff516c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -35,22 +35,16 @@ public class Buffer<T> implements QueueBuffer<T> {
index = new AtomicRangeInteger(0, bufferSize);
}
@Override
public void setStrategy(BufferStrategy strategy) {
this.strategy = strategy;
}
@Override
public boolean save(T data) {
int i = index.getAndIncrement();
if (buffer[i] != null) {
switch (strategy) {
case BLOCKING:
while (buffer[i] != null) {
try {
Thread.sleep(1L);
} catch (InterruptedException e) {
}
}
break;
case IF_POSSIBLE:
return false;
default:
@ -60,10 +54,12 @@ public class Buffer<T> implements QueueBuffer<T> {
return true;
}
@Override
public int getBufferSize() {
return buffer.length;
}
@Override
public void obtain(List<T> consumeList) {
this.obtain(consumeList, 0, buffer.length);
}