org.objectweb.jonathan.resources.lib
Class JScheduler

java.lang.Object
  extended byorg.objectweb.jonathan.resources.lib.JScheduler
All Implemented Interfaces:
Scheduler

public class JScheduler
extends Object
implements Scheduler

Default scheduler implementation.

This implementation has exactly the same behaviour as the default Java scheduling.

This scheduler manages a pool of re-usable threads. The size of this pool may be customized in the bootstrap context.


Field Summary
protected  org.objectweb.jonathan.apis.kernel.ContextFactory context_factory
           
 boolean verbose
          Indicates whether warning message should be printed to stderr.
 
Constructor Summary
JScheduler(org.objectweb.jonathan.apis.kernel.ContextFactory context_factory)
          Returns a new scheduler.
JScheduler(int max_waiting, boolean verbose, org.objectweb.jonathan.apis.kernel.ContextFactory context_factory)
          Returns a new scheduler.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verbose

public boolean verbose
Indicates whether warning message should be printed to stderr.

This value is defined under the name "/jonathan/JScheduler/verbose" in the bootstrap context.

This variable is not used in the current implementation.


context_factory

protected org.objectweb.jonathan.apis.kernel.ContextFactory context_factory
Constructor Detail

JScheduler

public JScheduler(org.objectweb.jonathan.apis.kernel.ContextFactory context_factory)
Returns a new scheduler.

Parameters:
context_factory - a context factory.

JScheduler

public JScheduler(int max_waiting,
                  boolean verbose,
                  org.objectweb.jonathan.apis.kernel.ContextFactory context_factory)
Returns a new scheduler.

Parameters:
max_waiting - maximum number of idle threads
verbose - indicates whether warning messsages should be output on stderr.
context_factory - a context factory.
Method Detail

newJob

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

Specified by:
newJob in interface Scheduler
Returns:
a new job created by the scheduler.

getCurrent

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

Specified by:
getCurrent in interface Scheduler
Returns:
the currently executing job.

yield

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

This implementation calls the static yield() method on the Thread class.

Specified by:
yield in interface Scheduler

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.

This implementation calls the standard wait() method on the provided lock.

Specified by:
wait in interface Scheduler
Parameters:
lock - the lock identifier.
Throws:
InterruptedException

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.

This implementation calls the standard wait() method on the provided lock.

Specified by:
wait in interface Scheduler
Parameters:
lock - the lock identifier.
Throws:
InterruptedException

notify

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

This implementation calls the standard notify() method on the provided lock.

Specified by:
notify in interface Scheduler
Parameters:
lock - the lock identifier.

notifyAll

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

This implementation calls the standard notifyAll() method on the provided lock.

Specified by:
notifyAll in interface Scheduler
Parameters:
lock - the lock identifier.

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.

This implementation has nothing to do.

Specified by:
escape in interface Scheduler

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.

This implementation has nothing to do.

Specified by:
enter in interface Scheduler