use of lucee.runtime.thread.ChildThreadImpl in project Lucee by lucee.
the class ThreadTag method register.
public void register(Page currentPage, int threadIndex) throws PageException {
if (ACTION_RUN != action)
return;
Key name = name(true);
try {
// pc.getThreadScope(name);
Threads ts = ThreadTag.getThreadScope(pc, name, ThreadTag.LEVEL_ALL);
if (type == TYPE_DAEMON) {
if (ts != null)
throw new ApplicationException("could not create a thread with the name [" + name.getString() + "]. name must be unique within a request");
ChildThreadImpl ct = new ChildThreadImpl((PageContextImpl) pc, currentPage, name.getString(), threadIndex, attrs, false);
pc.setThreadScope(name, new ThreadsImpl(ct));
ct.setPriority(priority);
ct.setDaemon(false);
ct.start();
} else {
ChildThreadImpl ct = new ChildThreadImpl((PageContextImpl) pc, currentPage, name.getString(), threadIndex, attrs, true);
ct.setPriority(priority);
((ConfigImpl) pc.getConfig()).getSpoolerEngine().add(new ChildSpoolerTask(ct, plans));
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
} finally {
// this method is not called from template when type is run, a call from template is to early,
((PageContextImpl) pc).reuse(this);
}
}
Aggregations