Class Job
- All Implemented Interfaces:
Comparable<org.eclipse.core.internal.jobs.InternalJob>
,IAdaptable
- Direct Known Subclasses:
AnimationUtil.FadeJob
,BasicUIJob
,org.eclipse.core.internal.resources.InternalWorkspaceJob
,ProvisioningJob
,UIJob
,WorkerJob
Jobs have a state that indicates what they are currently doing. When constructed,
jobs start with a state value of NONE
. When a job is scheduled
to be run, it moves into the WAITING
state. When a job starts
running, it moves into the RUNNING
state. When execution finishes
(either normally or through cancelation), the state changes back to
NONE
.
A job can also be in the SLEEPING
state. This happens if a user
calls Job.sleep() on a waiting job, or if a job is scheduled to run after a specified
delay. Only jobs in the WAITING
state can be put to sleep.
Sleeping jobs can be woken at any time using Job.wakeUp(), which will put the
job back into the WAITING
state.
Jobs can be assigned a priority that is used as a hint about how the job should
be scheduled. There is no guarantee that jobs of one priority will be run before
all jobs of lower priority. The javadoc for the various priority constants provide
more detail about what each priority means. By default, jobs start in the
LONG
priority class.
- Since:
- 3.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IStatus
Job status return value that is used to indicate asynchronous job completion.static final int
Job priority constant (value 40) for build jobs.static final int
Job priority constant (value 50) for decoration jobs.static final int
Job priority constant (value 10) for interactive jobs.static final int
Job priority constant (value 30) for long-running background jobs.static final int
Job state code (value 0) indicating that a job is not currently sleeping, waiting, or running (i.e., the job manager doesn't know anything about the job).static final int
Job state code (value 4) indicating that a job is currently runningstatic final int
Job priority constant (value 20) for short background jobs.static final int
Job state code (value 1) indicating that a job is sleeping.static final int
Job state code (value 2) indicating that a job is waiting to run.Fields inherited from class org.eclipse.core.internal.jobs.InternalJob
manager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addJobChangeListener
(IJobChangeListener listener) Registers a job listener with this job Has no effect if an identical listener is already registered.boolean
Returns whether this job belongs to the given family.final boolean
cancel()
Stops the job.protected void
A hook method indicating that this job is running andcancel()
is being called for the first time.static Job
create
(String name, ICoreRunnable runnable) Creates a new Job that will execute the provided runnable when it runs.static Job
create
(String name, IJobFunction function) Creates a new Job that will execute the provided function when it runs.static Job
createSystem
(String name, ICoreRunnable runnable) Creates a new systemJob
with the given name that will execute the provided runnable when it runs.static Job
createSystem
(String name, IJobFunction function) Creates a new systemJob
with the given name that will execute the provided function when it runs.final void
Jobs that complete their execution asynchronously must indicate when they are finished by calling this method.final JobGroup
Returns the job group this job belongs to, ornull
if this job does not belongs to any group.static final IJobManager
Returns the job manager.final String
getName()
Returns the human readable name of this job.final int
Returns the priority of this job.final Object
getProperty
(QualifiedName key) Returns the value of the property of this job identified by the given key, ornull
if this job has no such property.final IStatus
Returns the result of this job's last run.final ISchedulingRule
getRule()
Returns the scheduling rule for this job.final int
getState()
Returns the state of the job.final Thread
Returns the thread that this job is currently running in.final boolean
Returns whether this job is blocking a higher priority non-system job from starting due to a conflicting scheduling rule.final boolean
isSystem()
Returns whether this job is a system job.final boolean
isUser()
Returns whether this job has been directly initiated by a UI end user.final void
join()
Waits until this job is finished.final boolean
join
(long timeoutMillis, IProgressMonitor monitor) Waits until either the job is finished or the given timeout has expired.final void
removeJobChangeListener
(IJobChangeListener listener) Removes a job listener from this job.protected abstract IStatus
run
(IProgressMonitor monitor) Executes this job.final void
schedule()
Schedules this job to be run.final void
schedule
(long delay) Schedules this job to be run after a specified delay.final void
setJobGroup
(JobGroup jobGroup) Sets the job group to which this job belongs.final void
Changes the name of this job.final void
setPriority
(int priority) Sets the priority of the job.final void
setProgressGroup
(IProgressMonitor group, int ticks) Associates this job with a progress group.void
setProperty
(QualifiedName key, Object value) Sets the value of the property of this job identified by the given key.final void
setRule
(ISchedulingRule rule) Sets the scheduling rule to be used when scheduling this job.final void
setSystem
(boolean value) Sets whether or not this job is a system job.final void
Sets the thread that this job is currently running in, ornull
if this job is not running or the thread is unknown.final void
setUser
(boolean value) Sets whether or not this job has been directly initiated by a UI end user.boolean
Returns whether this job should be run.boolean
Returns whether this job should be scheduled.final boolean
sleep()
Requests that this job be suspended.toString()
Returns a string representation of this job to be used for debugging purposes only.final void
wakeUp()
Puts this job immediately into theWAITING
state so that it is eligible for immediate execution.final void
wakeUp
(long delay) Puts this job back into theWAITING
state after the specified delay.yieldRule
(IProgressMonitor monitor) Methods inherited from class org.eclipse.core.internal.jobs.InternalJob
compareTo
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
-
Field Details
-
ASYNC_FINISH
Job status return value that is used to indicate asynchronous job completion.- See Also:
-
INTERACTIVE
public static final int INTERACTIVEJob priority constant (value 10) for interactive jobs. Interactive jobs generally have priority over all other jobs. Interactive jobs should be either fast running or very low on CPU usage to avoid blocking other interactive jobs from running. -
SHORT
public static final int SHORTJob priority constant (value 20) for short background jobs. Short background jobs are jobs that typically complete within a second, but may take longer in some cases. Short jobs are given priority over all other jobs except interactive jobs. -
LONG
public static final int LONGJob priority constant (value 30) for long-running background jobs. -
BUILD
public static final int BUILDJob priority constant (value 40) for build jobs. Build jobs are generally run after all other background jobs complete. -
DECORATE
public static final int DECORATEJob priority constant (value 50) for decoration jobs. Decoration jobs have lowest priority. Decoration jobs generally compute extra information that the user may be interested in seeing but is generally not waiting for. -
NONE
public static final int NONEJob state code (value 0) indicating that a job is not currently sleeping, waiting, or running (i.e., the job manager doesn't know anything about the job).- See Also:
-
SLEEPING
public static final int SLEEPINGJob state code (value 1) indicating that a job is sleeping. -
WAITING
public static final int WAITINGJob state code (value 2) indicating that a job is waiting to run. -
RUNNING
public static final int RUNNINGJob state code (value 4) indicating that a job is currently running- See Also:
-
-
Constructor Details
-
Job
Creates a new job with the specified name. The job name is a human-readable value that is displayed to users. The name does not need to be unique, but it must not benull
.- Parameters:
name
- the name of the job.
-
-
Method Details
-
getJobManager
Returns the job manager.- Returns:
- the job manager
- Since:
- org.eclipse.core.jobs 3.2
-
create
Creates a new Job that will execute the provided function when it runs. Prefer usingcreate(String, ICoreRunnable)
as this does not require to call done on the monitor and relies on OperationCanceledException- Parameters:
name
- The name of the jobfunction
- The function to execute- Returns:
- A job that encapsulates the provided function
- Since:
- 3.6
- See Also:
-
create
Creates a new Job that will execute the provided runnable when it runs.- Parameters:
name
- the name of the jobrunnable
- the runnable to execute- Returns:
- a job that encapsulates the provided runnable
- Since:
- 3.8
- See Also:
-
createSystem
Creates a new systemJob
with the given name that will execute the provided function when it runs. Prefer usingcreateSystem(String, ICoreRunnable)
as this does not require to call done on the monitor and relies on OperationCanceledException- Parameters:
name
- the name of the jobfunction
- The function to execute- Returns:
- a job that encapsulates the provided function
- Since:
- 3.10
- See Also:
-
createSystem
Creates a new systemJob
with the given name that will execute the provided runnable when it runs.- Parameters:
name
- the name of the jobrunnable
- the runnable to execute- Returns:
- a job that encapsulates the provided runnable
- Since:
- 3.8
- See Also:
-
addJobChangeListener
Registers a job listener with this job Has no effect if an identical listener is already registered.- Overrides:
addJobChangeListener
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
listener
- the listener to be added.
-
belongsTo
Returns whether this job belongs to the given family. Job families are represented as objects that are not interpreted or specified in any way by the job manager. Thus, a job can choose to belong to any number of families.Clients may override this method. This default implementation always returns
false
. Overriding implementations must returnfalse
for families they do not recognize.- Overrides:
belongsTo
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
family
- the job family identifier- Returns:
true
if this job belongs to the given family, andfalse
otherwise.
-
cancel
public final boolean cancel()Stops the job. If the job is currently waiting, it will be removed from the queue. If the job is sleeping, it will be discarded without having a chance to resume and its sleeping state will be cleared. If the job is currently executing, it will be asked to stop but there is no guarantee that it will do so.- Overrides:
cancel
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
false
if the job is currently running (and thus may not respond to cancelation), andtrue
in all other cases.
-
canceling
protected void canceling()A hook method indicating that this job is running andcancel()
is being called for the first time.Subclasses may override this method to perform additional work when a cancelation request is made. This default implementation does nothing.
- Overrides:
canceling
in classorg.eclipse.core.internal.jobs.InternalJob
- Since:
- 3.3
-
done
Jobs that complete their execution asynchronously must indicate when they are finished by calling this method. This method must not be called by a job that has not indicated that it is executing asynchronously.This method must not be called from within the scope of a job's
run
method. Jobs should normally indicate completion by returning an appropriate status from therun
method. Jobs that return a status ofASYNC_FINISH
from their run method must later calldone
to indicate completion.- Overrides:
done
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
result
- a status object indicating the result of the job's execution.- See Also:
-
getName
Returns the human readable name of this job. The name is nevernull
.- Overrides:
getName
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
- the name of this job
-
getPriority
public final int getPriority()Returns the priority of this job. The priority is used as a hint when the job is scheduled to be run.- Overrides:
getPriority
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
- the priority of the job. One of INTERACTIVE, SHORT, LONG, BUILD, or DECORATE.
-
getProperty
Returns the value of the property of this job identified by the given key, ornull
if this job has no such property.- Overrides:
getProperty
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
key
- the name of the property- Returns:
- the value of the property,
or
null
if this job has no such property - See Also:
-
getResult
Returns the result of this job's last run.- Overrides:
getResult
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
- the result of this job's last run, or
null
if this job has never finished running.
-
getRule
Returns the scheduling rule for this job. Returnsnull
if this job has no scheduling rule.- Overrides:
getRule
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
- the scheduling rule for this job, or
null
. - See Also:
-
getState
public final int getState()Returns the state of the job. Result will be one of:Job.RUNNING
- if the job is currently running.Job.WAITING
- if the job is waiting to be run.Job.SLEEPING
- if the job is sleeping.Job.NONE
- in all other cases.
Note that job state is inherently volatile, and in most cases clients cannot rely on the result of this method being valid by the time the result is obtained. For example, if
getState
returnsRUNNING
, the job may have actually completed by the time thegetState
method returns. All clients can infer from invoking this method is that the job was recently in the returned state.- Overrides:
getState
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
- the job state
-
getThread
Returns the thread that this job is currently running in.- Overrides:
getThread
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
- the thread this job is running in, or
null
if this job is not running or the thread is unknown.
-
getJobGroup
Returns the job group this job belongs to, ornull
if this job does not belongs to any group.- Overrides:
getJobGroup
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
- the job group this job belongs to, or
null
. - Since:
- 3.7
- See Also:
-
isBlocking
public final boolean isBlocking()Returns whether this job is blocking a higher priority non-system job from starting due to a conflicting scheduling rule. Returnsfalse
if this job is not running, or is not blocking a higher priority non-system job.- Overrides:
isBlocking
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
true
if this job is blocking a higher priority non-system job, andfalse
otherwise.- See Also:
-
isSystem
public final boolean isSystem()Returns whether this job is a system job. System jobs are typically not revealed to users in any UI presentation of jobs. Other than their UI presentation, system jobs act exactly like other jobs. If this value is not explicitly set, jobs are treated as non-system jobs. The default value isfalse
.- Overrides:
isSystem
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
true
if this job is a system job, andfalse
otherwise.- See Also:
-
isUser
public final boolean isUser()Returns whether this job has been directly initiated by a UI end user. These jobs may be presented differently in the UI. The default value isfalse
.- Overrides:
isUser
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
true
if this job is a user-initiated job, andfalse
otherwise.- See Also:
-
join
Waits until this job is finished. This method will block the calling thread until the job has finished executing, or until this thread has been interrupted. If the job has not been scheduled, this method returns immediately. A job must not be joined from within the scope of its run method.If this method is called on a job that reschedules itself from within the
run
method, the join will return at the end of the first execution. In other words, join will return the first time this job exits theRUNNING
state, or as soon as this job enters theNONE
state.If this method is called while the job manager is suspended, this job will only be joined if it is already running; if this job is waiting or sleeping, this method returns immediately.
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.
Joining on another job belonging to the same group is not allowed if the group enforces throttling due to the potential for deadlock. For example, when the maximum threads allowed is set to 1 and a currently running Job A issues a join on another Job B belonging to its own job group, A waits indefinitely for its join to finish, but B never gets to run. To avoid that an IllegalStateException is thrown when a job tries to join another job belonging to the same job group. Joining another job belonging to the same group is allowed when the job group does not enforce throttling (JobGroup#getMaxThreads is zero).
Calling this method is equivalent to calling
join(0, null)
and it is recommended to use the other join method with timeout and progress monitor as that will provide more control over the join operation.- Overrides:
join
in classorg.eclipse.core.internal.jobs.InternalJob
- Throws:
InterruptedException
- if this thread is interrupted while waitingIllegalStateException
- when a job tries to join on itself or join on another job belonging to the same job group and the group is configured with non zero maximum threads allowed.- See Also:
-
join
public final boolean join(long timeoutMillis, IProgressMonitor monitor) throws InterruptedException, OperationCanceledException Waits until either the job is finished or the given timeout has expired. This method will block the calling thread until the job has finished executing, or the given timeout is expired, or the given progress monitor is canceled by the user or the calling thread is interrupted. If the job has not been scheduled, this method returns immediately. A job must not be joined from within the scope of its run method.If this method is called on a job that reschedules itself from within the
run
method, the join will return at the end of the first execution. In other words, join will return the first time this job exits theRUNNING
state, or as soon as this job enters theNONE
state.If this method is called while the job manager is suspended, this job will only be joined if it is already running; if this job is waiting or sleeping, this method returns immediately.
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 and the timeout is set zero (i.e no timeout), deadlock will occur.
Joining on another job belonging to the same group is not allowed if the timeout is set to zero and the group enforces throttling due to the potential for deadlock. For example, when the maximum threads allowed is set to 1 and a currently running Job A issues a join with no timeout on another Job B belonging to its own job group, A waits indefinitely for its join to finish, but B never gets to run. To avoid that an IllegalStateException is thrown when a job tries to join (with no timeout) another job belonging to the same job group. Joining another job belonging to the same group is allowed when either the job group does not enforce throttling (JobGroup#getMaxThreads is zero) or a non zero timeout value is provided.
Throws an
OperationCanceledException
when the given progress monitor is canceled. Canceling the monitor does not cancel the job and, if required, the job may be canceled explicitly using thecancel()
method.- Overrides:
join
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
timeoutMillis
- the maximum amount of time to wait for the join to complete, orzero
for no timeout.monitor
- the progress monitor that can be used to cancel the join operation, ornull
if cancellation is not required. No progress is reported on this monitor.- Returns:
true
when the job completes, orfalse
when the operation is not completed within the given time.- Throws:
InterruptedException
- if this thread is interrupted while waitingIllegalStateException
- when a job tries to join on itself or join with no timeout on another job belonging to the same job group and the group is configured with non-zero maximum threads allowed.OperationCanceledException
- if the progress monitor is canceled while waiting- Since:
- 3.7
- See Also:
-
removeJobChangeListener
Removes a job listener from this job. Has no effect if an identical listener is not already registered.- Overrides:
removeJobChangeListener
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
listener
- the listener to be removed
-
run
Executes this job. Returns the result of the execution.The provided monitor can be used to report progress and respond to cancellation. If the progress monitor has been canceled, the job should finish its execution at the earliest convenience and return a result status of severity
IStatus.CANCEL
. The singleton cancel statusStatus.CANCEL_STATUS
can be used for this purpose. The monitor is only valid for the duration of the invocation of this method.This method must not be called directly by clients. Clients should call
schedule
, which will in turn cause this method to be called.Jobs can optionally finish their execution asynchronously (in another thread) by returning a result status of
ASYNC_FINISH
. Jobs that finish asynchronously must specify the execution thread by callingsetThread
, and must indicate when they are finished by calling the methoddone
.- Specified by:
run
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
monitor
- the monitor to be used for reporting progress and responding to cancelation. The monitor is nevernull
- Returns:
- resulting status of the run. The result must not be
null
- See Also:
-
schedule
public final void schedule()Schedules this job to be run. The job is added to a queue of waiting jobs, and will be run when it arrives at the beginning of the queue.This is a convenience method, fully equivalent to
schedule(0L)
.- See Also:
-
schedule
public final void schedule(long delay) Schedules this job to be run after a specified delay. The job is put in theSLEEPING
state until the specified delay has elapsed, after which the job is added to a queue ofWAITING
jobs. Once the job arrives at the beginning of the queue, it will be run at the first available opportunity.Jobs of equal priority and
delay
with conflicting scheduling rules are guaranteed to run in the order they are scheduled. No guarantees are made about the relative execution order of jobs with unrelated ornull
scheduling rules, or different priorities.If this job is currently running, it will be rescheduled with the specified delay as soon as it finishes. If this method is called multiple times while the job is running, the job will still only be rescheduled once, with the most recent delay value that was provided.
Scheduling a job that is waiting or sleeping has no effect.
- Overrides:
schedule
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
delay
- a time delay in milliseconds before the job should run- See Also:
-
setName
Changes the name of this job. If the job is currently running, waiting, or sleeping, the new job name may not take effect until the next time the job is scheduled.The job name is a human-readable value that is displayed to users. The name does not need to be unique, but it must not be
null
.- Overrides:
setName
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
name
- the name of the job.
-
setPriority
public final void setPriority(int priority) Sets the priority of the job. This will not affect the execution of a running job, but it will affect how the job is scheduled while it is waiting to be run.- Overrides:
setPriority
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
priority
- the new job priority. One of INTERACTIVE, SHORT, LONG, BUILD, or DECORATE.
-
setProgressGroup
Associates this job with a progress group. Progress feedback on this job's next execution will be displayed together with other jobs in that group. The provided monitor must be a monitor created by the methodIJobManager.createProgressGroup
and must have at leastticks
units of available work.The progress group must be set before the job is scheduled. The group will be used only for a single invocation of the job's
run
method, after which any association of this job to the group will be lost.- Overrides:
setProgressGroup
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
group
- The progress group to use for this jobticks
- the number of work ticks allocated from the parent monitor, orIProgressMonitor.UNKNOWN
- See Also:
-
setProperty
Sets the value of the property of this job identified by the given key. If the supplied value isnull
, the property is removed from this resource.Properties are intended to be used as a caching mechanism by ISV plug-ins. They allow key-object associations to be stored with a job instance. These key-value associations are maintained in memory (at all times), and the information is never discarded automatically.
The qualifier part of the property name must be the unique identifier of the declaring plug-in (e.g.
"com.example.plugin"
).- Overrides:
setProperty
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
key
- the qualified name of the propertyvalue
- the value of the property, ornull
if the property is to be removed- See Also:
-
setRule
Sets the scheduling rule to be used when scheduling this job. This method must be called before the job is scheduled.- Overrides:
setRule
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
rule
- the new scheduling rule, ornull
if the job should have no scheduling rule- See Also:
-
setSystem
public final void setSystem(boolean value) Sets whether or not this job is a system job. System jobs are typically not revealed to users in any UI presentation of jobs. Other than their UI presentation, system jobs act exactly like other jobs. If this value is not explicitly set, jobs are treated as non-system jobs. This method must be called before the job is scheduled.- Overrides:
setSystem
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
value
-true
if this job should be a system job, andfalse
otherwise.- See Also:
-
setUser
public final void setUser(boolean value) Sets whether or not this job has been directly initiated by a UI end user. These jobs may be presented differently in the UI. This method must be called before the job is scheduled.- Overrides:
setUser
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
value
-true
if this job is a user-initiated job, andfalse
otherwise.- See Also:
-
setThread
Sets the thread that this job is currently running in, ornull
if this job is not running or the thread is unknown.Jobs that use the
ASYNC_FINISH
return code should tell the job what thread it is running in. This is used to prevent deadlocks.- Overrides:
setThread
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
thread
- the thread that this job is running in.- See Also:
-
setJobGroup
Sets the job group to which this job belongs. This method must be called before the job is scheduled, otherwise anIllegalStateException
is thrown.- Overrides:
setJobGroup
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
jobGroup
- the group to which this job belongs to, ornull
if this job does not belongs to any group.- Since:
- 3.7
- See Also:
-
shouldRun
public boolean shouldRun()Returns whether this job should be run. Iffalse
is returned, this job will be discarded by the job manager without running.This method is called immediately prior to calling the job's run method, so it can be used for last minute precondition checking before a job is run. This method must not attempt to schedule or change the state of any other job.
Clients may override this method. This default implementation always returns
true
.- Returns:
true
if this job should be run andfalse
otherwise
-
shouldSchedule
public boolean shouldSchedule()Returns whether this job should be scheduled. Iffalse
is returned, this job will be discarded by the job manager without being added to the queue.This method is called immediately prior to adding the job to the waiting job queue.,so it can be used for last minute precondition checking before a job is scheduled.
Clients may override this method. This default implementation always returns
true
.- Overrides:
shouldSchedule
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
true
if the job manager should schedule this job andfalse
otherwise
-
sleep
public final boolean sleep()Requests that this job be suspended. If the job is currently waiting to be run, it will be removed from the queue move into theSLEEPING
state. The job will remain asleep until either resumed or canceled. If this job is not currently waiting to be run, this method has no effect.Sleeping jobs can be resumed using
wakeUp
.- Overrides:
sleep
in classorg.eclipse.core.internal.jobs.InternalJob
- Returns:
false
if the job is currently running (and thus cannot be put to sleep), andtrue
in all other cases- See Also:
-
toString
Returns a string representation of this job to be used for debugging purposes only.- Overrides:
toString
in classorg.eclipse.core.internal.jobs.InternalJob
- Since:
- org.eclipse.core.jobs 3.5
-
wakeUp
public final void wakeUp()Puts this job immediately into theWAITING
state so that it is eligible for immediate execution. If this job is not currently sleeping, the request is ignored.This is a convenience method, fully equivalent to
wakeUp(0L)
.- See Also:
-
wakeUp
public final void wakeUp(long delay) Puts this job back into theWAITING
state after the specified delay. This is equivalent to canceling the sleeping job and rescheduling with the given delay. If this job is not currently sleeping, the request is ignored.- Overrides:
wakeUp
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
delay
- the number of milliseconds to delay- See Also:
-
yieldRule
Temporarily puts thisJob
back intoWAITING
state and relinquishes the job's scheduling rule so that anyWAITING
jobs that conflict with this job's scheduling rule have an opportunity to start. This method will wait until the rule this job held prior to invoking this method is re-acquired. This method has no effect and returnsnull
if there are noWAITING
jobs that conflict with this job's scheduling rule.Note: If this job has acquired any other locks, implicit or explicit, they will not be released. This may increase the risk of deadlock, so this method should only be used when it is known that the environment is safe.
This method must be invoked by this job's
Thread
, and only when it isRUNNING
state.- Overrides:
yieldRule
in classorg.eclipse.core.internal.jobs.InternalJob
- Parameters:
monitor
- a progress monitor, ornull
if progress reporting is not desired. Cancellation attempts will be ignored.- Returns:
- The Job that was
WAITING
, and blocked by thisJob
(at the time this method was invoked) that was unblocked and allowed a chance to run, ornull
if no jobs were unblocked. Note: it is not guaranteed that thisJob
resume immediately if other conflicting jobs are also waiting after the unblocked job ends. - Since:
- org.eclipse.core.jobs 3.5
- See Also:
-