public class BackgroundCompiler
extends java.lang.Object
This is necessary as we cannot block the main thread.
| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_DISABLE_AT_PERM_GEN
The default fraction of perm gen space after which the background compiler will be disabled.
|
static ReportType |
REPORT_CANNOT_COMPILE_STRUCTURE_MODIFIER |
static ReportType |
REPORT_CANNOT_SCHEDULE_COMPILATION |
static int |
SHUTDOWN_DELAY_MS |
static java.lang.String |
THREAD_FORMAT
The default format for the name of new worker threads.
|
| Constructor and Description |
|---|
BackgroundCompiler(java.lang.ClassLoader loader,
ErrorReporter reporter)
Initialize a background compiler.
|
BackgroundCompiler(java.lang.ClassLoader loader,
ErrorReporter reporter,
java.util.concurrent.ExecutorService executor)
Initialize a background compiler utilizing the given thread pool.
|
| Modifier and Type | Method and Description |
|---|---|
<TKey> void |
addListener(StructureModifier<TKey> uncompiled,
CompileListener<TKey> listener)
Add a compile listener if we are still waiting for the structure modifier to be compiled.
|
StructureCompiler |
getCompiler()
Retrieve the current structure compiler.
|
double |
getDisablePermGenFraction()
Retrieve the fraction of perm gen space used after which the background compiler will be disabled.
|
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 |
setDisablePermGenFraction(double fraction)
Set the fraction of perm gen space used after which the background compiler will be disabled.
|
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 ReportType REPORT_CANNOT_COMPILE_STRUCTURE_MODIFIER
public static final ReportType REPORT_CANNOT_SCHEDULE_COMPILATION
public static final java.lang.String THREAD_FORMAT
public static final int SHUTDOWN_DELAY_MS
public static final double DEFAULT_DISABLE_AT_PERM_GEN
public BackgroundCompiler(java.lang.ClassLoader loader,
ErrorReporter reporter)
Uses the default THREAD_FORMAT to name worker threads.
loader - - class loader from Bukkit.reporter - - current error reporter.public BackgroundCompiler(java.lang.ClassLoader loader,
ErrorReporter reporter,
java.util.concurrent.ExecutorService executor)
loader - - class loader from Bukkit.reporter - - current error reporter.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 <TKey> void addListener(StructureModifier<TKey> uncompiled, CompileListener<TKey> listener)
uncompiled - - the structure modifier that may get compiled.listener - - the listener to invoke in that case.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 double getDisablePermGenFraction()
public void setDisablePermGenFraction(double fraction)
fraction - - the maximum use of perm gen space.public StructureCompiler getCompiler()