public class ThreadMonitorImpl<Script> extends Object implements ExecuteMonitor<Script>, ExecuteResult<Script>
При старте запускает скрипт в отредльном треде (а если надо, то и ThreadGroup)
| Modifier and Type | Field and Description |
|---|---|
protected ClassLoader |
cl |
protected Boolean |
daemon |
protected String |
name |
protected Integer |
prio |
protected Script |
script |
protected Throwable |
scriptError |
protected Object |
scriptResult |
protected xyz.cofe.collection.Func0<xyz.cofe.collection.Pair<Object,Throwable>> |
scriptRun |
protected boolean |
tgFinishNotifyOnError |
protected Thread |
thread |
protected ThreadGroup |
threadGroup |
| Constructor and Description |
|---|
ThreadMonitorImpl(Script script,
xyz.cofe.collection.Func0<xyz.cofe.collection.Pair<Object,Throwable>> run)
Конструктор
|
| Modifier and Type | Method and Description |
|---|---|
ThreadMonitorImpl<Script> |
cancel()
Отмена выполнения.
|
protected Thread |
createThread() |
static List<Thread> |
exclude(Iterable<Thread> thList,
xyz.cofe.collection.Func1<Boolean,Thread> filter) |
static List<Thread> |
filter(Iterable<Thread> thList,
xyz.cofe.collection.Func1<Boolean,Thread> filter) |
static List<Thread> |
filter(Iterable<Thread> thList,
xyz.cofe.collection.Predicate<Thread> filter) |
long |
getCancelDelay() |
long |
getCancelTimeout() |
ClassLoader |
getContextClassLoader() |
Boolean |
getDaemon() |
Throwable |
getError()
Ошибка выполнения
|
xyz.cofe.collection.Func1<Boolean,Thread> |
getExcludeFilter() |
Date |
getFinished()
Дата завершения выполнения скрипта
|
Integer |
getPrio() |
Object |
getResult()
Результат выполнения
|
Script |
getScript()
Возвращает выполняемый/выполненый скрипт
|
Date |
getStarted()
Дата начала выполнения скрипта
|
Thread |
getThread() |
ThreadGroup |
getThreadGroup() |
String |
getThreadName() |
boolean |
isRunning()
Проверяет состояние выполнения
|
boolean |
isTgFinishNotifyOnError() |
ThreadMonitorImpl<Script> |
join()
Ждет завершения скрипта
|
ThreadMonitorImpl<Script> |
join(long millis)
Ждет завершения скрипта, указанное время
|
Closeable |
onFinished(xyz.cofe.common.Reciver<ExecuteResult<Script>> consumer)
При завершении выполнения вызывает указанного "подписчика"
|
Closeable |
onFinished(xyz.cofe.common.Reciver<ExecuteResult<Script>> consumer,
boolean weakListener)
При завершении выполнения вызывает указанного "подписчика"
|
void |
onThreadCreated(xyz.cofe.common.Reciver<Thread> consumer) |
void |
setCancelDelay(long ms) |
void |
setCancelTimeout(long ms) |
void |
setContextClassLoader(ClassLoader cl) |
void |
setDaemon(Boolean daemon) |
void |
setExcludeFilter(xyz.cofe.collection.Func1<Boolean,Thread> excludeFilter) |
void |
setFinished(Date d) |
void |
setPrio(Integer p) |
void |
setTgFinishNotifyOnError(boolean tgFinishNotifyOnError) |
void |
setThreadGroup(ThreadGroup tg) |
void |
setThreadName(String name) |
ThreadMonitorImpl<Script> |
start()
Выполняет скрипт
|
ThreadMonitorImpl<Script> |
startCancel(xyz.cofe.common.Reciver<ExecuteResult<Script>> consumer)
Отмена выполнения асинхронно.
|
static List<Thread> |
threadsOf(ThreadGroup tg) |
protected ThreadGroup threadGroup
protected Integer prio
protected Boolean daemon
protected ClassLoader cl
protected String name
protected boolean tgFinishNotifyOnError
protected Thread thread
protected Script script
protected volatile Object scriptResult
protected volatile Throwable scriptError
public ThreadGroup getThreadGroup()
public void setThreadGroup(ThreadGroup tg)
public Integer getPrio()
public void setPrio(Integer p)
public Boolean getDaemon()
public void setDaemon(Boolean daemon)
public ClassLoader getContextClassLoader()
public void setContextClassLoader(ClassLoader cl)
public void setThreadName(String name)
public String getThreadName()
public void onThreadCreated(xyz.cofe.common.Reciver<Thread> consumer)
public boolean isTgFinishNotifyOnError()
public void setTgFinishNotifyOnError(boolean tgFinishNotifyOnError)
protected Thread createThread()
public Thread getThread()
public ThreadMonitorImpl<Script> start()
ExecuteMonitorstart in interface ExecuteMonitor<Script>public Script getScript()
ExecuteMonitorgetScript in interface ExecuteMonitor<Script>getScript in interface ExecuteResult<Script>public Object getResult()
ExecuteMonitorgetResult in interface ExecuteMonitor<Script>getResult in interface ExecuteResult<Script>public Throwable getError()
ExecuteMonitorgetError in interface ExecuteMonitor<Script>getError in interface ExecuteResult<Script>public boolean isRunning()
ExecuteMonitorisRunning in interface ExecuteMonitor<Script>public Date getStarted()
ExecuteMonitorgetStarted in interface ExecuteMonitor<Script>public Date getFinished()
ExecuteMonitorgetFinished in interface ExecuteMonitor<Script>public void setFinished(Date d)
public Closeable onFinished(xyz.cofe.common.Reciver<ExecuteResult<Script>> consumer, boolean weakListener)
ExecuteMonitoronFinished in interface ExecuteMonitor<Script>consumer - подписчик на сообщения завершения работыweakListener - добавить подписчика как weak ссылкуpublic Closeable onFinished(xyz.cofe.common.Reciver<ExecuteResult<Script>> consumer)
ExecuteMonitoronFinished in interface ExecuteMonitor<Script>consumer - подписчик на сообщения завершения работыpublic ThreadMonitorImpl<Script> cancel()
ExecuteMonitorcancel in interface ExecuteMonitor<Script>public ThreadMonitorImpl<Script> startCancel(xyz.cofe.common.Reciver<ExecuteResult<Script>> consumer)
ExecuteMonitorstartCancel in interface ExecuteMonitor<Script>consumer - - будет вызван по завершению операции отменыpublic long getCancelDelay()
public void setCancelDelay(long ms)
public long getCancelTimeout()
public void setCancelTimeout(long ms)
public ThreadMonitorImpl<Script> join()
ExecuteMonitorjoin in interface ExecuteMonitor<Script>public ThreadMonitorImpl<Script> join(long millis)
ExecuteMonitorjoin in interface ExecuteMonitor<Script>millis - время в милисек.public void setExcludeFilter(xyz.cofe.collection.Func1<Boolean,Thread> excludeFilter)
public static List<Thread> threadsOf(ThreadGroup tg)
public static List<Thread> exclude(Iterable<Thread> thList, xyz.cofe.collection.Func1<Boolean,Thread> filter)
public static List<Thread> filter(Iterable<Thread> thList, xyz.cofe.collection.Func1<Boolean,Thread> filter)
Copyright © 2019. All rights reserved.