org.objectweb.jonathan.resources.api
Interface Scheduler
- JScheduler
public interface Scheduler
Schedulers are used to create and schedule Jobs.
To allow application programmers to change the default scheduling used by Java,
and to implement some resource management policy on activity resources
(threads), Jonathan introduces abstractions to represent activities
(interface
Job
) and schedulers
(interface
Scheduler
).
A Job is the abstraction of an activity in the system. When this activity
is sequential
(the usual case), it may be thought of as a thread. The role of a scheduler is
to create Jobs (a scheduler is a job factory), and to manage them according to
their properties (a priority, a deadline, ...). A scheduler has thus the
responsibility to associate a Job with some processing resource (which may be
a processor, or more simply a Java thread) when it is entitled to run.
void | enter() - Causes a job
"escaped" from the scheduler to be re-admitted
in the set of jobs managed by the target scheduler.
|
void | escape() - Causes the calling job to be removed from the set of jobs managed by the
target scheduler.
|
Job | getCurrent() - Returns the currently executing job (the job performing the call).
|
Job | newJob() - Returns a new job created by the scheduler.
|
void | notify(Object lock) - Unblocks a job
waiting on the lock.
|
void | notifyAll(Object lock) - Unblocks all jobs
waiting on the lock.
|
void | wait(Object lock) - Blocks the calling job until the
notify or
notifyAll method is called providing the
same lock identifier.
|
void | wait(Object lock, long millis) - Blocks the calling job until the
notify or
notifyAll method is called providing the
same lock identifier.
|
void | yield() - Calling this method gives the opportunity to the scheduler to re-schedule
the currently executing jobs.
|
enter
public void enter()
Causes a job
"escaped"
from the scheduler to be re-admitted
in the set of jobs managed by the target scheduler.
escape
public void escape()
Causes the calling job to be removed from the set of jobs managed by the
target scheduler. It is necessary to call this method before every possibly
blocking method so that the scheduler can give a chance to run to another job.
getCurrent
public Job getCurrent()
Returns the currently executing job (the job performing the call).
- the currently executing job.
newJob
public Job newJob()
Returns a new job created by the scheduler.
- a new job created by the scheduler.
notify
public void notify(Object lock)
Unblocks a job
waiting
on the lock.
lock
- the lock identifier.
notifyAll
public void notifyAll(Object lock)
Unblocks all jobs
waiting
on the lock.
lock
- the lock identifier.
wait
public void wait(Object lock)
throws InterruptedException
Blocks the calling job until the
notify
or
notifyAll
method is called providing the
same lock identifier.
lock
- the lock identifier.
wait
public void wait(Object lock,
long millis)
throws InterruptedException
Blocks the calling job until the
notify
or
notifyAll
method is called providing the
same lock identifier.
lock
- the lock identifier.
yield
public void yield()
Calling this method gives the opportunity to the scheduler to re-schedule
the currently executing jobs.