/** Creates request that can be later started by setting its delay. * The request is not immediatelly put into the queue. It is planned after * setting its delay by schedule method. By default the initial state of * the task is <code>!isFinished()</code> so doing waitFinished() will * block on and wait until the task is scheduled. * * @param run action to run in the process * @return the task to control execution of given action */ public Task create(Runnable run) { return create(run, false); }
/** Creates request that can be later started by setting its delay. * The request is not immediatelly put into the queue. It is planned after * setting its delay by setDelay method. * @param run action to run in the process * @return the task to control execution of given action * * @deprecated Sharing of one singlethreaded <CODE>RequestProcessor</CODE> * among different users and posting even blocking requests is inherently * deadlock-prone. See <A href="#use_cases">use cases</A>. */ @Deprecated public static Task createRequest(Runnable run) { return DEFAULT.create(run); }
/** * Create a soft reference with timeout. * The supplied map serves double duty as a synchronization lock * for the reference's state changes. * @param o the referent * @param m a map in which this reference may serve as a value * @param k the key whose value in <code>m</code> may be this reference */ public TimedSoftReference(T o, Map m, Object k) { super(o, Utilities.activeReferenceQueue()); this.o = o; this.m = m; this.k = k; task = RP.create(this); task.schedule(TIMEOUT); }
private ScheduledFuture<?> scheduleFixed (Runnable command, long initialDelay, long period, TimeUnit unit, boolean fixedDelay) { Parameters.notNull("unit", unit); //NOI18N Parameters.notNull("command", command); //NOI18N if (period < 0) { throw new IllegalArgumentException ("Negative delay: " + period); //NOI18N } if (initialDelay < 0) { throw new IllegalArgumentException ("Negative initialDelay: " //NOI18N + initialDelay); } if (stopped) { throw new RejectedExecutionException("Request Processor already " + //NOI18N "stopped"); //NOI18N } long initialDelayMillis = TimeUnit.MILLISECONDS.convert(initialDelay, unit); long periodMillis = TimeUnit.MILLISECONDS.convert(period, unit); TaskFutureWrapper wrap = fixedDelay ? new FixedDelayTask(command, initialDelayMillis, periodMillis) : new FixedRateTask(command, initialDelay, periodMillis); Task t = create(wrap); wrap.t = t; t.cancelled = wrap.cancelled; t.schedule (initialDelayMillis); return wrap; }
/** * {@inheritDoc} * @since org.openide.util 8.2 */ @Override public <T> ScheduledFuture<T> schedule(Callable<T> callable, long delay, TimeUnit unit) { Parameters.notNull("unit", unit); //NOI18N Parameters.notNull("callable", callable); //NOI18N if (delay < 0) { throw new IllegalArgumentException ("Negative delay: " + delay); } if (stopped) { throw new RejectedExecutionException("Request Processor already " + //NOI18N "stopped"); //NOI18N } long delayMillis = TimeUnit.MILLISECONDS.convert(delay, unit); ScheduledRPFutureTask<T> result = new ScheduledRPFutureTask<T>(callable, delayMillis); Task t = create(result); result.setTask(t); t.schedule(delayMillis); return result; }
refreshTask.cancel(); } else { refreshTask = REFRESH_RP.create(new Runnable() {
/** * {@inheritDoc} * @since org.openide.util 8.2 */ @Override public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { Parameters.notNull("command", command); //NOI18N Parameters.notNull("unit", unit); //NOI18N if (delay < 0) { throw new IllegalArgumentException ("Negative delay: " + delay); } if (stopped) { throw new RejectedExecutionException("Request Processor already stopped"); //NOI18N } long delayMillis = TimeUnit.MILLISECONDS.convert(delay, unit); ScheduledRPFutureTask<Void> result = new ScheduledRPFutureTask<Void>(command, null, delayMillis); Task t = create(result); result.setTask(t); t.schedule(delayMillis); return result; } /**
/** * {@inheritDoc} * <b>Note:</b> If the passed {@link java.lang.Runnable} implements * {@link org.openide.util.Cancellable}, then that object's {@link org.openide.util.Cancellable#cancel()} * method will be called if {@link java.util.concurrent.Future#cancel(boolean)} is invoked. * If <code>Cancellable.cancel()</code> returns false, then <i>the job will <u>not</u> be * cancelled</i>. * @since org.openide.util 8.2 */ @Override public <T> Future<T> submit(Runnable task, T predefinedResult) { Parameters.notNull("task", task); //NOI18N if (stopped) { throw new RejectedExecutionException("Request Processor already " + //NOI18N "stopped"); //NOI18N } RPFutureTask<T> result = new RPFutureTask<T>(task, predefinedResult); Task t = create(result); result.setTask(t); t.schedule(0); return result; }
/** * {@inheritDoc} * <p/> * <b>Note:</b> If the passed {@link java.util.concurrent.Callable} implements * {@link org.openide.util.Cancellable}, then that object's {@link org.openide.util.Cancellable#cancel()} * method will be called if {@link java.util.concurrent.Future#cancel(boolean)} is invoked. * If <code>Cancellable.cancel()</code> returns false, then <i>the job will <u>not</u> be * cancelled</i>. * @since org.openide.util 8.2 */ @Override public <T> Future<T> submit(Callable<T> task) { Parameters.notNull("task", task); //NOI18N if (stopped) { throw new RejectedExecutionException("Request Processor already " + //NOI18N "stopped"); //NOI18N } RPFutureTask<T> result = new RPFutureTask<T>(task); Task t = create(result); result.setTask(t); t.schedule(0); return result; } /**
/** * Create a new AsyncChildren instance with the passed provider object * which will manufacture key objects and nodes. * @param factory An object which can provide a list of keys and make * Nodes for them */ AsynchChildren(ChildFactory<T> factory) { this.factory = factory; task = PROC.create(this, true); }
task = reqProc.create( new Runnable() { public void run() {
task = reqProc.create( new Runnable() { public void run() {
private void refsMayChanged() { // check project state whenever there was a property change // or change in list of platforms. // Coalesce changes since they can come quickly: if (task == null) { task = RP.create(this); } task.schedule(100); }
public synchronized void refreshModel() { if (task == null) { task = BROKEN_DATASOURCE_RP.create(this); } task.schedule(50); }
public void propertyChange(PropertyChangeEvent evt) { synchronized (this) { if (saveTask == null) saveTask = RequestProcessor.getDefault().create(this); } synchronized (this) { keepAlive.add(evt); } saveTask.schedule(DELAY); }
ActionStateUpdater(ExplorerManager m) { timer = RP.create(this); weakL = WeakListeners.propertyChange(this, m); m.addPropertyChangeListener(weakL); }
public BaseMakeViewChildren(Folder folder, MakeLogicalViewProvider provider) { this.folder = folder; this.provider = provider; keyUpdater = new KeyUpdater(); this.refreshKeysTask = provider.getAnnotationRP().create(keyUpdater, true); }
public DoInitialize(QuietEditorPane tmp) { this.tmp = tmp; this.tmpComp = initLoading(); new Timer(1000, this).start(); if (newInitialize()) { task = RP.create(this); task.setPriority(Thread.MIN_PRIORITY + 2); task.schedule(0); } else { run(); } }
private void updateAnnotationFiles() { if (updateTask == null) { updateTask = provider.getAnnotationRP().create(new FileAnnotationUpdater(this)); } updateTask.schedule(BaseMakeViewChildren.WAIT_DELAY); // batch by 50 ms }
/** Creates new form SelectModePanel */ public SelectModePanel(SelectModeDescriptorPanel controller) { this.controller = controller; initComponents(); instructions.setEditorKit(new HTMLEditorKit()); instructions.setBackground(instructionPanel.getBackground()); disableHostSensitiveComponents(); refreshRunnable = new RefreshRunnable(); refreshSourceFolderTask = RP2.create(refreshRunnable); addListeners(); }