1
0
forked from xjboss/KCauldronX
This commit is contained in:
Prototik 2015-10-21 23:37:43 +07:00
parent 40ac2b7e23
commit 6458549af6
2 changed files with 114 additions and 108 deletions

View File

@ -1,8 +1,10 @@
# This file is generated by GitLab CI # This file is generated by GitLab CI
Source test: Source test:
script: script:
- rm -rf $(grep path .gitmodules | awk '{print $3}')
- git submodule update --init --recursive - git submodule update --init --recursive
- ./gradlew clean setupCauldron jar - ./gradlew clean setupCauldron jar
- rm -rf $(grep path .gitmodules | awk '{print $3}')
tags: tags:
- test - test
except: except:
@ -10,8 +12,10 @@ Source test:
Deploy: Deploy:
script: script:
- rm -rf $(grep path .gitmodules | awk '{print $3}')
- git submodule update --init --recursive - git submodule update --init --recursive
- ./gradlew -PofficialBuild clean setupCauldron publish - ./gradlew -PofficialBuild clean setupCauldron publish
- rm -rf $(grep path .gitmodules | awk '{print $3}')
type: deploy type: deploy
tags: tags:
- deploy - deploy
@ -25,6 +29,7 @@ Deploy:
Merge master into backport-1448: Merge master into backport-1448:
script: script:
- rm -rf $(grep path .gitmodules | awk '{print $3}')
- from=master - from=master
- to=backport-1448 - to=backport-1448
- git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git - git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git
@ -33,6 +38,7 @@ Merge master into backport-1448:
- git reset --hard origin/$to - git reset --hard origin/$to
- git merge origin/$from - git merge origin/$from
- git push origin $to - git push origin $to
- rm -rf $(grep path .gitmodules | awk '{print $3}')
type: deploy type: deploy
tags: tags:
- merge-backport - merge-backport
@ -41,6 +47,7 @@ Merge master into backport-1448:
Merge backport-1448 into backport-1388: Merge backport-1448 into backport-1388:
script: script:
- rm -rf $(grep path .gitmodules | awk '{print $3}')
- from=backport-1448 - from=backport-1448
- to=backport-1388 - to=backport-1388
- git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git - git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git
@ -49,6 +56,7 @@ Merge backport-1448 into backport-1388:
- git reset --hard origin/$to - git reset --hard origin/$to
- git merge origin/$from - git merge origin/$from
- git push origin $to - git push origin $to
- rm -rf $(grep path .gitmodules | awk '{print $3}')
type: deploy type: deploy
tags: tags:
- merge-backport - merge-backport
@ -57,6 +65,7 @@ Merge backport-1448 into backport-1388:
Merge backport-1388 into backport-1370: Merge backport-1388 into backport-1370:
script: script:
- rm -rf $(grep path .gitmodules | awk '{print $3}')
- from=backport-1388 - from=backport-1388
- to=backport-1370 - to=backport-1370
- git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git - git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git
@ -65,6 +74,7 @@ Merge backport-1388 into backport-1370:
- git reset --hard origin/$to - git reset --hard origin/$to
- git merge origin/$from - git merge origin/$from
- git push origin $to - git push origin $to
- rm -rf $(grep path .gitmodules | awk '{print $3}')
type: deploy type: deploy
tags: tags:
- merge-backport - merge-backport
@ -73,6 +83,7 @@ Merge backport-1388 into backport-1370:
Merge backport-1370 into backport-1291: Merge backport-1370 into backport-1291:
script: script:
- rm -rf $(grep path .gitmodules | awk '{print $3}')
- from=backport-1370 - from=backport-1370
- to=backport-1291 - to=backport-1291
- git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git - git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git
@ -81,6 +92,7 @@ Merge backport-1370 into backport-1291:
- git reset --hard origin/$to - git reset --hard origin/$to
- git merge origin/$from - git merge origin/$from
- git push origin $to - git push origin $to
- rm -rf $(grep path .gitmodules | awk '{print $3}')
type: deploy type: deploy
tags: tags:
- merge-backport - merge-backport
@ -89,6 +101,7 @@ Merge backport-1370 into backport-1291:
Merge backport-1291 into backport-1240: Merge backport-1291 into backport-1240:
script: script:
- rm -rf $(grep path .gitmodules | awk '{print $3}')
- from=backport-1291 - from=backport-1291
- to=backport-1240 - to=backport-1240
- git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git - git remote set-url origin gitlab@prok.pw:Prototik/KCauldron.git
@ -97,6 +110,7 @@ Merge backport-1291 into backport-1240:
- git reset --hard origin/$to - git reset --hard origin/$to
- git merge origin/$from - git merge origin/$from
- git push origin $to - git push origin $to
- rm -rf $(grep path .gitmodules | awk '{print $3}')
type: deploy type: deploy
tags: tags:
- merge-backport - merge-backport

View File

@ -6,127 +6,119 @@ import java.util.Queue;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class ProcessingQueue<T> extends QueueWrapper<T> { public class ProcessingQueue<T> extends QueueWrapper<T> {
public class ProcessingIterator implements Iterator<T> { public class ProcessingIterator implements Iterator<T> {
private Iterator<T> mRealIterator = mCollection.iterator(); private Iterator<T> mRealIterator = mCollection.iterator();
private AtomicInteger mPosition = new AtomicInteger(0);
@Override @Override
public boolean hasNext() { public boolean hasNext() {
final int size = mSize.get(); return mRealIterator.hasNext();
final int position = mPosition.get(); }
if (size == 0 || position >= size) {
mPosition.compareAndSet(position, 0);
mRealIterator = mCollection.iterator();
return false;
}
boolean value = mRealIterator.hasNext();
if (!value) {
mRealIterator = mCollection.iterator();
value = mRealIterator.hasNext();
}
return value;
}
@Override @Override
public T next() { public T next() {
T value = mRealIterator.next(); return mRealIterator.next();
mPosition.incrementAndGet(); }
return value;
}
@Override @Override
public void remove() { public void remove() {
mRealIterator.remove(); mRealIterator.remove();
mSize.decrementAndGet(); mSize.decrementAndGet();
mPosition.decrementAndGet(); }
} }
public void reset() { private final AtomicInteger mSize;
mPosition.set(0);
}
}
private final AtomicInteger mSize; @Override
private final ProcessingIterator mIterator = new ProcessingIterator(); public boolean add(T e) {
boolean result = super.add(e);
if (result) {
mSize.incrementAndGet();
}
return result;
};
@Override @Override
public boolean add(T e) { public boolean offer(T e) {
boolean result = super.add(e); boolean result = super.offer(e);
if (result) { if (result) {
mSize.incrementAndGet(); mSize.incrementAndGet();
} }
return result; return result;
}; }
@Override @Override
public boolean offer(T e) { public boolean addAll(Collection<? extends T> c) {
boolean result = super.offer(e); boolean result = false;
if (result) { for (T t : c) {
mSize.incrementAndGet(); result |= add(t);
} }
return result; return result;
} }
@Override @Override
public boolean addAll(Collection<? extends T> c) { public T remove() {
boolean result = false; T result = super.remove();
for (T t : c) { mSize.decrementAndGet();
result |= add(t); return result;
} }
return result;
}
@Override @Override
public T remove() { public boolean remove(Object o) {
T result = super.remove(); boolean result = super.remove(o);
mSize.decrementAndGet(); if (result) {
return result; mSize.decrementAndGet();
} }
return result;
}
@Override @Override
public boolean remove(Object o) { public boolean removeAll(Collection<?> c) {
boolean result = super.remove(o); boolean result = false;
if (result) { for (Object t : c) {
mSize.decrementAndGet(); result |= remove(t);
} }
return result; return result;
} }
@Override @Override
public boolean removeAll(Collection<?> c) { public boolean retainAll(Collection<?> c) {
boolean result = false; boolean result = super.retainAll(c);
for (Object t : c) { if (result) {
result |= remove(t); mSize.set(mCollection.size());
} }
return result; return result;
} }
@Override @Override
public boolean retainAll(Collection<?> c) { public T poll() {
boolean result = super.retainAll(c); T result = super.remove();
if (result) { if (result != null) {
mSize.set(mCollection.size()); mSize.decrementAndGet();
} }
return result; return result;
} }
@Override public ProcessingQueue(Queue<T> collection) {
public T poll() { super(collection);
T result = super.remove(); mSize = new AtomicInteger(collection.size());
if (result != null) { }
mSize.decrementAndGet();
}
return result;
}
public ProcessingQueue(Queue<T> collection) { @Override
super(collection); public ProcessingIterator iterator() {
mSize = new AtomicInteger(collection.size()); return new ProcessingIterator();
} }
@Override @Override
public ProcessingIterator iterator() { public String toString() {
mIterator.reset(); if (size() == 0)
return mIterator; return "[]";
} StringBuilder builder = new StringBuilder();
for (T t : this) {
builder.append(',');
builder.append(t == null ? "null" : t.getClass().getSimpleName());
}
builder.setCharAt(0, '[');
builder.append(']');
return builder.toString();
}
} }