* @param delay how long to delay initially.
* @return the newly created queue.
*/
public TimedQueue forceToTimed(Duration delay) {
stop();
TimedQueue newQueue = TimedQueue.getQueue(id);
for (ScriptEntry entry: getEntries()) {
entry.setInstant(true);
}
newQueue.addEntries(getEntries());
for (Map.Entry<String, String> def: getAllDefinitions().entrySet()) {
newQueue.addDefinition(def.getKey(), def.getValue());
}
for (Map.Entry<String, dObject> entry: getAllContext().entrySet()) {
newQueue.addContext(entry.getKey(), entry.getValue());
}
for (Map.Entry<String, ScriptEntry> entry: held_entries.entrySet()) {
newQueue.holdScriptEntry(entry.getKey(), entry.getValue());
}
newQueue.setLastEntryExecuted(getLastEntryExecuted());
clear();
if (delay != null)
newQueue.delayFor(delay);
newQueue.start();
return newQueue;
}