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, wait
getAverageCallbackContextCount, getAverageReferenceCount, getAverageV8HeapSpaceStatistics, getAverageV8HeapStatistics, getAverageV8ModuleCount
protected 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 IJavetClosable
close
in interface java.lang.AutoCloseable
JavetException
protected JavetEngine<R> createEngine() throws JavetException
JavetException
- the javet exceptionpublic int getActiveEngineCount()
IJavetEnginePool
getActiveEngineCount
in interface IJavetEnginePool<R extends V8Runtime>
public JavetEngineConfig getConfig()
IJavetEnginePool
getConfig
in interface IJavetEnginePool<R extends V8Runtime>
public IJavetEngine<R> getEngine() throws JavetException
IJavetEnginePool
getEngine
in interface IJavetEnginePool<R extends V8Runtime>
JavetException
- the javet exceptionpublic int getIdleEngineCount()
IJavetEnginePool
getIdleEngineCount
in interface IJavetEnginePool<R extends V8Runtime>
public int getReleasedEngineCount()
IJavetEnginePool
getReleasedEngineCount
in interface IJavetEnginePool<R extends V8Runtime>
protected java.time.ZonedDateTime getUTCNow()
public V8SharedMemoryStatistics getV8SharedMemoryStatistics()
IJavetEnginePool
getV8SharedMemoryStatistics
in interface IJavetEnginePool<R extends V8Runtime>
public boolean isActive()
IJavetEnginePool
isActive
in interface IJavetEnginePool<R extends V8Runtime>
public boolean isClosed()
IJavetClosable
isClosed
in interface IJavetClosable
public boolean isQuitting()
IJavetEnginePool
isQuitting
in interface IJavetEnginePool<R extends V8Runtime>
public int observe(IV8RuntimeObserver<?>... observers)
IJavetEnginePool
observe
in interface IJavetEnginePool<R extends V8Runtime>
observers
- the observerspublic void releaseEngine(IJavetEngine<R> iJavetEngine)
IJavetEnginePool
releaseEngine
in interface IJavetEnginePool<R extends V8Runtime>
iJavetEngine
- the javet enginepublic void run()
run
in interface java.lang.Runnable
protected void startDaemon()
protected void stopDaemon()
public void wakeUpDaemon()
IJavetEnginePool
wakeUpDaemon
in interface IJavetEnginePool<R extends V8Runtime>