R - the type parameterpublic class JavetEnginePool<R extends V8Runtime> extends java.lang.Object implements IJavetEnginePool<R>, java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
active
The Active.
|
protected JavetEngineConfig |
config
The Config.
|
protected java.lang.Thread |
daemonThread
The Daemon thread.
|
protected JavetEngine<R>[] |
engines
The Engines.
|
protected java.lang.Object |
externalLock
The External lock.
|
protected java.util.concurrent.ConcurrentLinkedQueue<java.lang.Integer> |
idleEngineIndexList
The Idle engine index list.
|
protected java.lang.Object |
internalLock
The Internal lock.
|
protected static java.lang.String |
JAVET_DAEMON_THREAD_NAME
The constant JAVET_DAEMON_THREAD_NAME.
|
protected boolean |
quitting
The Quitting.
|
protected java.util.Random |
random
The Random.
|
protected java.util.concurrent.ConcurrentLinkedQueue<java.lang.Integer> |
releasedEngineIndexList
The Released engine index list.
|
protected java.util.concurrent.Semaphore |
semaphore
The Semaphore.
|
| Constructor and Description |
|---|
JavetEnginePool()
Instantiates a new Javet engine pool.
|
JavetEnginePool(JavetEngineConfig config)
Instantiates a new Javet engine pool.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected JavetEngine<R> |
createEngine()
Create engine javet engine.
|
int |
getActiveEngineCount()
Gets active engine count.
|
JavetEngineConfig |
getConfig()
Gets config.
|
IJavetEngine<R> |
getEngine()
Gets engine.
|
int |
getIdleEngineCount()
Gets idle engine count.
|
int |
getReleasedEngineCount()
Gets released engine count.
|
protected java.time.ZonedDateTime |
getUTCNow()
Gets utc now.
|
V8SharedMemoryStatistics |
getV8SharedMemoryStatistics()
Gets V8 shared memory statistics.
|
boolean |
isActive()
Is active.
|
boolean |
isClosed()
Is closed.
|
boolean |
isQuitting()
Is quitting boolean.
|
int |
observe(IV8RuntimeObserver<?>... observers)
Traverse the internal V8 runtimes, apply the observer and return the observed V8 runtime count.
|
void |
releaseEngine(IJavetEngine<R> iJavetEngine)
Release engine.
|
void |
run() |
protected void |
startDaemon()
Start daemon.
|
protected void |
stopDaemon()
Stop daemon.
|
void |
wakeUpDaemon()
Wake up the daemon thread explicitly.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAverageCallbackContextCount, getAverageReferenceCount, getAverageV8HeapSpaceStatistics, getAverageV8HeapStatistics, getAverageV8ModuleCountprotected static final java.lang.String JAVET_DAEMON_THREAD_NAME
protected final java.lang.Object externalLock
protected final java.util.concurrent.ConcurrentLinkedQueue<java.lang.Integer> idleEngineIndexList
protected final java.lang.Object internalLock
protected final java.util.concurrent.ConcurrentLinkedQueue<java.lang.Integer> releasedEngineIndexList
protected volatile boolean active
protected JavetEngineConfig config
protected java.lang.Thread daemonThread
protected JavetEngine<R extends V8Runtime>[] engines
protected volatile boolean quitting
protected java.util.Random random
protected java.util.concurrent.Semaphore semaphore
public JavetEnginePool()
public JavetEnginePool(JavetEngineConfig config)
config - the configpublic void close()
throws JavetException
close in interface IJavetClosableclose in interface java.lang.AutoCloseableJavetExceptionprotected JavetEngine<R> createEngine() throws JavetException
JavetException - the javet exceptionpublic int getActiveEngineCount()
IJavetEnginePoolgetActiveEngineCount in interface IJavetEnginePool<R extends V8Runtime>public JavetEngineConfig getConfig()
IJavetEnginePoolgetConfig in interface IJavetEnginePool<R extends V8Runtime>public IJavetEngine<R> getEngine() throws JavetException
IJavetEnginePoolgetEngine in interface IJavetEnginePool<R extends V8Runtime>JavetException - the javet exceptionpublic int getIdleEngineCount()
IJavetEnginePoolgetIdleEngineCount in interface IJavetEnginePool<R extends V8Runtime>public int getReleasedEngineCount()
IJavetEnginePoolgetReleasedEngineCount in interface IJavetEnginePool<R extends V8Runtime>protected java.time.ZonedDateTime getUTCNow()
public V8SharedMemoryStatistics getV8SharedMemoryStatistics()
IJavetEnginePoolgetV8SharedMemoryStatistics in interface IJavetEnginePool<R extends V8Runtime>public boolean isActive()
IJavetEnginePoolisActive in interface IJavetEnginePool<R extends V8Runtime>public boolean isClosed()
IJavetClosableisClosed in interface IJavetClosablepublic boolean isQuitting()
IJavetEnginePoolisQuitting in interface IJavetEnginePool<R extends V8Runtime>public int observe(IV8RuntimeObserver<?>... observers)
IJavetEnginePoolobserve in interface IJavetEnginePool<R extends V8Runtime>observers - the observerspublic void releaseEngine(IJavetEngine<R> iJavetEngine)
IJavetEnginePoolreleaseEngine in interface IJavetEnginePool<R extends V8Runtime>iJavetEngine - the javet enginepublic void run()
run in interface java.lang.Runnableprotected void startDaemon()
protected void stopDaemon()
public void wakeUpDaemon()
IJavetEnginePoolwakeUpDaemon in interface IJavetEnginePool<R extends V8Runtime>