Add getMergePrimaryThreadAndClear.

This commit is contained in:
asofold 2018-01-28 17:33:53 +01:00
parent e7aa12141a
commit 1de1c37d29
1 changed files with 12 additions and 0 deletions

View File

@ -335,6 +335,18 @@ public abstract class DualCollection<T, C extends Collection<T>> {
return primaryThreadCollection.iterator();
}
/**
* Return a merged collection and clear internal ones - primary thread only.
*
* @return Returns null, if no elements are contained.
*/
public Collection<T> getMergePrimaryThreadAndClear() {
mergePrimaryThread();
final Collection<T> res = this.primaryThreadCollection;
this.primaryThreadCollection = null;
return (res == null || res.isEmpty()) ? null : res;
}
/**
* Clear the primary thread collection. <br>
* Primary thread only.