se.lth.cs.realtime.event
Class ConfigureEvent

java.lang.Object
  extended byjava.util.EventObject
      extended byse.lth.cs.realtime.event.RTEvent
          extended byse.lth.cs.realtime.event.ActivityEvent
              extended byse.lth.cs.realtime.event.ConfigureEvent
All Implemented Interfaces:
java.io.Serializable

public abstract class ConfigureEvent
extends ActivityEvent

Basic support for in-process and buffered reconfiguration of threads, as defined by providing a subclass with suitable configure method(s). The usage scenario is explained by the following example:
Assume a master thread M sends orders to a slave thread S, which normally runs with priority NORM_PRIORITY during the processing of it. After having processed a certain event e0, S should be instructed to change priority to MAX_PRIORITY. M cannot call S.setPriority since it may not be done before e0 is processed, and M must continue producing new orders. Hence, the set-priority order has to be buffered along with the application events, and carried out within the context of S. In code this means for M:

     S.putEvent(e0);
     S.putEvent(new ConfigureEvent(){
         public void configure(Thread self){
             self.setPriority(Thread.MAX_PRIORITY);
         }
         public void configure(RTThread self){
             self.setPriority(RTThread.MAX_PRIORITY);
         }
     )
 
If we know what type of thread M is, one of these methods could (of course) be omitted. Then in S, no matter if S is an RT thread or not, we trust M and call configure:
     ev = mailbox.doFetch();
     while (ev instanceof ConfigureEvent) {
         ((ConfigureEvent)ev).configure(this);
         ev = mailbox.doFetch();
     }
 
These lines could of course comprise a getEvent method, but to reduce code and complexity in the simple/normal case, threads accepting event-driven reconfigurations are to include this or similar code where appropriate.

Another examples could be change of period, and the configure method could send back an AckEvent when done. The ActivityEvent is designed to be independent of specific thread methods and application needs.

See Also:
License, Serialized Form

Field Summary
 
Fields inherited from class se.lth.cs.realtime.event.RTEvent
owner, ticker, timestamp
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
ConfigureEvent(Activity source)
          Constructs a ConfigureEvent object with the specified source thread and identifier.
 
Method Summary
 void configure(RTThread self)
          Configuration or reconfiguration of real-time threads.
 void configure(java.lang.Thread self)
          Configuration or reconfiguration of Java/concurrent threads, as defined by subclassing in the event-posting thread.
 
Methods inherited from class se.lth.cs.realtime.event.RTEvent
getMillis, getNanos, getOwner, getSeconds, getTicks, getTimebase, paramString, setOwner, toString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigureEvent

public ConfigureEvent(Activity source)
Constructs a ConfigureEvent object with the specified source thread and identifier.

Parameters:
source - the thread where the event originated.
Method Detail

configure

public void configure(RTThread self)
Configuration or reconfiguration of real-time threads.

Parameters:
self - the real-time thread to be (re)configured, typically this in the event-fetching thread.

configure

public void configure(java.lang.Thread self)
Configuration or reconfiguration of Java/concurrent threads, as defined by subclassing in the event-posting thread.

Parameters:
self - the thread object to be (re)configured, typically this in the event-fetching thread.