mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-03 01:19:42 +01:00
Add ChunkHashTable.awaitCompletion().
This commit is contained in:
parent
5ddc4b9251
commit
5b685e71d3
@ -40,6 +40,7 @@
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -132,6 +133,25 @@ private void rebuild() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits until all currently executing background tasks complete.
|
||||||
|
*
|
||||||
|
* @param timeout the maximum time to wait
|
||||||
|
* @param unit the time unit of the timeout argument
|
||||||
|
* @return {@code true} if this executor terminated and
|
||||||
|
* {@code false} if the timeout elapsed before termination
|
||||||
|
* @throws InterruptedException on interruption
|
||||||
|
*/
|
||||||
|
public boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException {
|
||||||
|
ListeningExecutorService previousExecutor;
|
||||||
|
synchronized (lock) {
|
||||||
|
previousExecutor = executor;
|
||||||
|
executor = createExecutor();
|
||||||
|
}
|
||||||
|
previousExecutor.shutdown();
|
||||||
|
return previousExecutor.awaitTermination(timeout, unit);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bias(Vector2D chunkPosition) {
|
public void bias(Vector2D chunkPosition) {
|
||||||
checkNotNull(chunkPosition);
|
checkNotNull(chunkPosition);
|
||||||
|
Loading…
Reference in New Issue
Block a user