public class BackgroundCompiler
extends java.lang.Object
This is necessary as we cannot block the main thread.
Modifier and Type | Field and Description |
---|---|
static int |
SHUTDOWN_DELAY_MS |
Constructor and Description |
---|
BackgroundCompiler(java.lang.ClassLoader loader)
Initialize a background compiler.
|
BackgroundCompiler(java.lang.ClassLoader loader,
java.util.concurrent.ExecutorService executor)
Initialize a background compiler utilizing the given thread pool.
|
Modifier and Type | Method and Description |
---|---|
StructureCompiler |
getCompiler()
Retrieve the current structure compiler.
|
static BackgroundCompiler |
getInstance()
Retrieves the current background compiler.
|
boolean |
isEnabled()
Retrieve whether or not the background compiler is enabled.
|
void |
scheduleCompilation(java.util.Map<java.lang.Class,StructureModifier> cache,
java.lang.Class key)
Ensure that the indirectly given structure modifier is eventually compiled.
|
<TKey> void |
scheduleCompilation(StructureModifier<TKey> uncompiled,
CompileListener<TKey> listener)
Ensure that the given structure modifier is eventually compiled.
|
void |
setEnabled(boolean enabled)
Sets whether or not the background compiler is enabled.
|
static void |
setInstance(BackgroundCompiler backgroundCompiler)
Sets the single background compiler we're using.
|
void |
shutdownAll()
Clean up after ourselves using the default timeout.
|
void |
shutdownAll(long timeout,
java.util.concurrent.TimeUnit unit)
Clean up after ourselves.
|
public static final int SHUTDOWN_DELAY_MS
public BackgroundCompiler(java.lang.ClassLoader loader)
loader
- - class loader from Bukkit.public BackgroundCompiler(java.lang.ClassLoader loader, java.util.concurrent.ExecutorService executor)
loader
- - class loader from Bukkit.executor
- - thread pool we'll use.public static BackgroundCompiler getInstance()
public static void setInstance(BackgroundCompiler backgroundCompiler)
backgroundCompiler
- - current background compiler, or NULL if the library is not loaded.public void scheduleCompilation(java.util.Map<java.lang.Class,StructureModifier> cache, java.lang.Class key)
cache
- - store of structure modifiers.key
- - key of the structure modifier to compile.public <TKey> void scheduleCompilation(StructureModifier<TKey> uncompiled, CompileListener<TKey> listener)
uncompiled
- - structure modifier to compile.listener
- - listener responsible for responding to the compilation.public void shutdownAll()
public void shutdownAll(long timeout, java.util.concurrent.TimeUnit unit)
timeout
- - the maximum time to wait.unit
- - the time unit of the timeout argument.public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled
- - TRUE to enable it, FALSE otherwise.public StructureCompiler getCompiler()