Class ResourceUnitExample2

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc

    public class ResourceUnitExample2
    extends SchedulingElement
    This example illustrate the use of a ResourceUnit via a simple M/M/1 queue. It is important to understand that a Request has everything it needs to work with the resource unit, including the service time. When the request is allocated to the resource unit, the time required for the request is used to determine the amount of time that the resource is used and after that time the request is completed. The resource unit causes state changes that can be reacted to via the RequestReactorIfc interface or the use of RequestReactorAdapter. If the resource unit is not available, the resource unit will automatically queue the request in an internal request queue associated with the resource unit. The request is placed in the waiting state. A state change for the request occurs when it is enqueued. When the unit becomes available the request is removed from the waiting state (dequeued state change) and is allocated the resource, after allocation the request begins using the resource unit according to the time provided on the request. The request is consider to be in the allocated state. After the requested time is over, the request is placed in the completed state. Again, user of the Request can listen to the state changes via the RequestReactorIfc interface. An instance of a class implementing this interface must be supplied when the request is made so that the call-backs can occur during the state changes. Whether or not the reactor does anything with the notification is up to the client. This example, different from ResourceUnitExample1 illustrated the mirroring of the queueing by using the request reactor. When a request is made, an object can be associated with the request. In this example code, a QObject representing a customer is associated with the request. The code then uses a separate Queue instance to enqueue and dequeue the customer when the customer's associated request experiences is notified that it is enqueue or dequeued. From the statistics, you can see that the results are the same. Similarly a time weighted variable is used to track whether or not the resource is busy based on the allocated and completed state changes on the request.
    • Method Detail

      • setServiceRS

        public final void setServiceRS​(RandomIfc d)
      • setArrivalRS

        public final void setArrivalRS​(RandomIfc d)
      • initialize

        protected void initialize()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called
        Overrides:
        initialize in class ModelElement
      • main

        public static void main​(java.lang.String[] args)