public interface IJobManager
schedule
method.Modifier and Type | Field and Description |
---|---|
static String |
PROP_USE_DAEMON_THREADS
A system property key indicating whether the job manager should create
job threads as daemon threads.
|
Modifier and Type | Method and Description |
---|---|
void |
addJobChangeListener(IJobChangeListener listener)
Registers a job listener with the job manager.
|
void |
beginRule(ISchedulingRule rule,
IProgressMonitor monitor)
Begins applying this rule in the calling thread.
|
void |
cancel(Object family)
Cancels all jobs in the given job family.
|
IProgressMonitor |
createProgressGroup()
Returns a progress monitor that can be used to provide
aggregated progress feedback on a set of running jobs.
|
Job |
currentJob()
Returns the job that is currently running in this thread, or
null if there
is no currently running job. |
ISchedulingRule |
currentRule()
Returns the scheduling rule currently held by this thread, or
null
if the current thread does not hold any scheduling rule. |
void |
endRule(ISchedulingRule rule)
Ends the application of a rule to the calling thread.
|
Job[] |
find(Object family)
Returns all waiting, executing and sleeping jobs belonging
to the given family.
|
boolean |
isIdle()
Returns whether the job manager is currently idle.
|
boolean |
isSuspended()
Returns whether the job manager is currently suspended.
|
void |
join(Object family,
IProgressMonitor monitor)
Waits until all jobs of the given family are finished.
|
ILock |
newLock()
Creates a new lock object.
|
void |
removeJobChangeListener(IJobChangeListener listener)
Removes a job listener from the job manager.
|
void |
resume()
Resumes execution of jobs after a previous
suspend . |
void |
resume(ISchedulingRule rule)
Deprecated.
This method is not safe and should not be used.
Suspending a scheduling rule violates the thread safety
of clients that use scheduling rules as a mutual exclusion mechanism,
and can result in concurrency problems in all clients that use the suspended rule.
|
void |
setLockListener(LockListener listener)
Provides a hook that is notified whenever a thread is about to wait on a lock,
or when a thread is about to release a lock.
|
void |
setProgressProvider(ProgressProvider provider)
Registers a progress provider with the job manager.
|
void |
sleep(Object family)
Requests that all jobs in the given job family be suspended.
|
void |
suspend()
Suspends execution of all jobs.
|
void |
suspend(ISchedulingRule rule,
IProgressMonitor monitor)
Deprecated.
This method is not safe and should not be used.
Suspending a scheduling rule violates the thread safety
of clients that use scheduling rules as a mutual exclusion mechanism,
and can result in concurrency problems in all clients that use the suspended rule.
|
void |
transferRule(ISchedulingRule rule,
Thread destinationThread)
Transfers ownership of a scheduling rule to another thread.
|
void |
wakeUp(Object family)
Resumes scheduling of all sleeping jobs in the given family.
|
static final String PROP_USE_DAEMON_THREADS
true
to force all worker
threads to be created as daemon threads. Set to false
to force
all worker threads to be created as non-daemon threads.void addJobChangeListener(IJobChangeListener listener)
listener
- the listener to be addedremoveJobChangeListener(IJobChangeListener)
,
IJobChangeListener
void beginRule(ISchedulingRule rule, IProgressMonitor monitor)
Rules can be nested only if the rule for the inner beginRule is contained within the rule for the outer beginRule. Rule containment is tested with the API method ISchedulingRule.contains. Also, begin/end pairs must be strictly nested. Only the rule that has most recently begun can be ended at any given time.
A rule of null
can be used, but will be ignored for scheduling
purposes. The outermost non-null rule in the thread will be used for scheduling. A
null
rule that is begun must still be ended.
If this method is called from within a job that has a scheduling rule, the given rule must also be contained within the rule for the running job.
Note that endRule must be called even if beginRule fails. The recommended usage is:
final ISchedulingRule rule = ...; try { manager.beginRule(rule, monitor); } finally { manager.endRule(rule); }
rule
- the rule to begin applying in this thread, or null
monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredIllegalArgumentException
- if the rule is not strictly nested within
all other rules currently active for this threadOperationCanceledException
- if the supplied monitor reports cancelation
before the rule becomes availableISchedulingRule.contains(ISchedulingRule)
void cancel(Object family)
family
- the job family to cancel, or null
to cancel all jobsJob.belongsTo(Object)
IProgressMonitor createProgressGroup()
Recommended usage (this snippet runs two jobs in sequence in a single progress group):
Job parseJob, compileJob; IProgressMonitor pm = Platform.getJobManager().createProgressGroup(); try { pm.beginTask("Building", 10); parseJob.setProgressGroup(pm, 5); parseJob.schedule(); compileJob.setProgressGroup(pm, 5); compileJob.schedule(); parseJob.join(); compileJob.join(); } finally { pm.done(); }
Job.setProgressGroup(IProgressMonitor, int)
,
IProgressMonitor
ISchedulingRule currentRule()
null
if the current thread does not hold any scheduling rule.
If this method is called from within the scope of a running job with a non-null
scheduling rule, then this method is equivalent to calling currentJob().getRule()
.
Otherwise, this method will return the first scheduling rule obtained by this
thread via beginRule(ISchedulingRule, IProgressMonitor)
that has not
yet had a corresponding call to endRule(ISchedulingRule)
.
null
Job currentJob()
null
if there
is no currently running job.null
void endRule(ISchedulingRule rule)
Rules can be nested only if the rule for the inner beginRule is contained within the rule for the outer beginRule. Also, begin/end pairs must be strictly nested. Only the rule that has most recently begun can be ended at any given time.
rule
- the rule to end applying in this threadIllegalArgumentException
- if this method is called on a rule for which
there is no matching begin, or that does not match the most recent begin.ISchedulingRule.contains(ISchedulingRule)
Job[] find(Object family)
family
- the job family to find, or null
to find all jobsJob.belongsTo(Object)
boolean isIdle()
true
if the job manager is idle, and
false
otherwiseboolean isSuspended()
void join(Object family, IProgressMonitor monitor) throws InterruptedException, OperationCanceledException
If this method is called while the job manager is suspended, only jobs
that are currently running will be joined; Once there are no jobs
in the family in the Job.RUNNING
state, this method returns.
Note that there is a deadlock risk when using join. If the calling thread owns a lock or object monitor that the joined thread is waiting for, deadlock will occur. This method can also result in starvation of the current thread if another thread continues to add jobs of the given family, or if a job in the given family reschedules itself in an infinite loop.
family
- the job family to join, or null
to join all jobs.monitor
- Progress monitor for reporting progress on how the
wait is progressing, or null
if no progress monitoring is required.InterruptedException
- if this thread is interrupted while waitingOperationCanceledException
- if the progress monitor is canceled while waitingJob.belongsTo(Object)
,
suspend()
ILock newLock()
void removeJobChangeListener(IJobChangeListener listener)
listener
- the listener to be removedaddJobChangeListener(IJobChangeListener)
,
IJobChangeListener
@Deprecated void resume(ISchedulingRule rule)
suspend
. All
jobs that were sleeping or waiting prior to the suspension, or that were
scheduled while the job manager was suspended, will now be eligible
for execution.
Calling this method on a rule that is not suspended has no effect. If another thread also owns the rule at the time this method is called, then the rule will not be resumed until all threads have released the rule.
void resume()
suspend
. All
jobs that were sleeping or waiting prior to the suspension, or that were
scheduled while the job manager was suspended, will now be eligible
for execution.
Calling resume
when the job manager is not suspended
has no effect.
suspend()
,
isSuspended()
void setLockListener(LockListener listener)
This method is for internal use by the platform-related plug-ins. Clients should not call this method.
LockListener
void setProgressProvider(ProgressProvider provider)
This method is intended for use by the currently executing Eclipse application. Plug-ins outside the currently running application should not call this method.
provider
- the new provider, or null
if no progress
is neededvoid suspend()
The job manager will remain suspended until a subsequent call to
resume
. Further calls to suspend
when the job manager is already suspended are ignored.
All attempts to join sleeping and waiting jobs while the job manager is suspended will return immediately.
Note that this very powerful function should be used with extreme caution. Suspending the job manager will prevent all jobs in the system from executing, which may have adverse affects on components that are relying on execution of jobs. The job manager should never be suspended without intent to resume execution soon afterwards.
resume()
,
join(Object, IProgressMonitor)
,
isSuspended()
@Deprecated void suspend(ISchedulingRule rule, IProgressMonitor monitor)
While a rule is suspended, all calls to beginRule
and
endRule
on a suspended rule will not block the caller.
The rule remains suspended until a subsequent call to
resume(ISchedulingRule)
with the identical rule instance.
Further calls to suspend
with an identical rule prior to calling
resume
are ignored.
This method is long-running; progress and cancelation are provided by the given progress monitor. In the case of cancelation, the rule will not be suspended.
Note: this very powerful function should be used with extreme caution. Suspending rules will prevent jobs in the system from executing, which may have adverse effects on components that are relying on execution of jobs. The job manager should never be suspended without intent to resume execution soon afterwards. Deadlock will result if the thread responsible for resuming the rule attempts to join a suspended job.rule
- The scheduling rule to suspend. Must not be null
.monitor
- a progress monitor, or null
if progress
reporting is not desiredOperationCanceledException
- if the operation is canceled.
Cancelation can occur even if no progress monitor is provided.resume(ISchedulingRule)
void sleep(Object family)
SLEEPING
state. Jobs that have been put to sleep
will remain in that state until either resumed or canceled. This method has
no effect on jobs that are not currently waiting to be run.
Sleeping jobs can be resumed using wakeUp
.
family
- the job family to sleep, or null
to sleep all jobs.Job.belongsTo(Object)
void transferRule(ISchedulingRule rule, Thread destinationThread)
beginRule
. The destination thread must
not already own a scheduling rule.
Calling this method is equivalent to atomically calling endRule
in the calling thread followed by an immediate beginRule
in
the destination thread. The destination thread is responsible for subsequently
calling endRule
when it is finished using the rule.
This method has no effect when the destination thread is the same as the calling thread.
rule
- The scheduling rule to transferdestinationThread
- The new owner for the transferred rule.void wakeUp(Object family)
family
- the job family to wake up, or null
to wake up all jobsJob.belongsTo(Object)
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.