org.objectweb.jonathan.resources.api
Interface Scheduler

All Known Implementing Classes:
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.


Method Summary
 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.
 

Method Detail

newJob

Job newJob()
Returns a new job created by the scheduler.

Returns:
a new job created by the scheduler.

getCurrent

Job getCurrent()
Returns the currently executing job (the job performing the call).

Returns:
the currently executing job.

yield

void yield()
Calling this method gives the opportunity to the scheduler to re-schedule the currently executing jobs.


wait

void wait(Object lock)
          throws InterruptedException
Blocks the calling job until the notify or notifyAll method is called providing the same lock identifier.

Parameters:
lock - the lock identifier.
Throws:
InterruptedException

wait

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.

Parameters:
lock - the lock identifier.
Throws:
InterruptedException

notify

void notify(Object lock)
Unblocks a job waiting on the lock.

Parameters:
lock - the lock identifier.

notifyAll

void notifyAll(Object lock)
Unblocks all jobs waiting on the lock.

Parameters:
lock - the lock identifier.

escape

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.


enter

void enter()
Causes a job "escaped" from the scheduler to be re-admitted in the set of jobs managed by the target scheduler.