fr.umlv.corosol.component.impl
Class DefaultJScheduler

java.lang.Object
  extended by fr.umlv.corosol.component.impl.AbstractJVMComponent
      extended by fr.umlv.corosol.component.impl.DefaultJScheduler
All Implemented Interfaces:
JObject, JScheduler, JVMComponent

public class DefaultJScheduler
extends AbstractJVMComponent
implements JScheduler

This is the default implementation of the JScheduler interface.

Author:
Christophe Deleray
See Also:
JScheduler

Constructor Summary
DefaultJScheduler()
          The default constructor.
 
Method Summary
 void breakScheduling()
          Stops the thread managing loop of this scheduler.
 void enqueueThread(JThread thread)
          Puts the specified thread in the thread queue of this scheduler.
 java.lang.Class getComponentClass()
          Returns the class object describing this component.
 JThread getCurrentThread()
          Returns the current executing thread.
 JThread[] getThreads()
          Returns all the active threads managed by this scheduler.
 boolean hasNext()
          Determines if there is a thread to be managed by this scheduler.
 void replace(JVMComponent component)
          Replaces the data of this scheduler by the data of the specified component.
 void schedule()
          Starts the thread managing loops of this scheduler.
 java.lang.String toString()
          Returns a string representation of this scheduler.
 
Methods inherited from class fr.umlv.corosol.component.impl.AbstractJVMComponent
configure
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fr.umlv.corosol.component.JVMComponent
configure
 

Constructor Detail

DefaultJScheduler

public DefaultJScheduler()
The default constructor.

Method Detail

getCurrentThread

public JThread getCurrentThread()
Returns the current executing thread.

Specified by:
getCurrentThread in interface JScheduler
Returns:
the current executing thread

enqueueThread

public void enqueueThread(JThread thread)
Puts the specified thread in the thread queue of this scheduler.

Specified by:
enqueueThread in interface JScheduler
Parameters:
thread - a new thread to be scheduled

schedule

public void schedule()
              throws java.lang.Throwable
Starts the thread managing loops of this scheduler. An extern component can break this loop by using the breakScheduling method.

Specified by:
schedule in interface JScheduler
Throws:
java.lang.Throwable - if an exception occurs during execution
See Also:
breakScheduling()

toString

public java.lang.String toString()
Returns a string representation of this scheduler.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this scheduler

getComponentClass

public java.lang.Class getComponentClass()
Returns the class object describing this component.

Specified by:
getComponentClass in interface JVMComponent

replace

public void replace(JVMComponent component)
Replaces the data of this scheduler by the data of the specified component. The type of component must be the type of this component. This method should be call when a component is replaced in the Corosol Virtual Machine.

Specified by:
replace in interface JVMComponent
Overrides:
replace in class AbstractJVMComponent
Parameters:
component - a component to be used to initialize this component

breakScheduling

public void breakScheduling()
Stops the thread managing loop of this scheduler. The threads still active are returned by the getThreads methods

Specified by:
breakScheduling in interface JScheduler
See Also:
getThreads()

getThreads

public JThread[] getThreads()
Returns all the active threads managed by this scheduler.

Specified by:
getThreads in interface JScheduler

hasNext

public boolean hasNext()
Determines if there is a thread to be managed by this scheduler. Returns true if any and false otherwise.

Specified by:
hasNext in interface JScheduler
Returns:
true if there is a thread to be managed by this scheduler. false otherwise.