Class LinearServerQueue<QS extends QueueServer>

All Implemented Interfaces:
QueueStatus, NamedObjectOps
Direct Known Subclasses:
FifoServerQueue, LifoServerQueue

public abstract class LinearServerQueue<QS extends QueueServer> extends ServerQueue<DelayTaskQueue.Parameter,QS>
Linear server queue. This implements a ServerQueue in which the entries are processed in linear order such as FIFO (First In, First Out) order.
See Also:
  • Constructor Details

    • LinearServerQueue

      protected LinearServerQueue(Simulation sim, String name, boolean intern, TaskQueue<DelayTaskQueue.Parameter> tq, QS... servers) throws IllegalArgumentException
      Constructor.
      Parameters:
      sim - the simulation
      name - the name of the queue
      intern - true if the queue name should be interned in the simulation tables; false otherwise
      tq - the task queue used to queue requests when all the servers are busy
      servers - the queue's servers
      Throws:
      IllegalArgumentException - typically means a name is already in use
  • Method Details

    • add

      public SimulationEvent add(QueueCallable<QS> callable, long delay)
      Add a QueueCallable to the queue given a processing-time interval. When the QueueCallable is scheduled and the corresponding event is processed, its call() method will be executed.
      Parameters:
      callable - the QueueCallable to add
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      Returns:
      the SimulationEvent created; null if the QueueCallable cannot be queued
    • add

      public SimulationEvent add(QueueCallable<QS> callable, long delay, double tpriority)
      Add a QueueCallable to the queue given a processing-time interval and time event priority. When the QueueCallable is scheduled and the corresponding event is processed, its call() method will be executed.
      Parameters:
      callable - the QueueCallable to add
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      tpriority - the time event priority
      Returns:
      the SimulationEvent created; null if the QueueCallable cannot be queued
    • add

      public SimulationEvent add(SimObjQueueCallable<QS> callable, long delay)
      Add a SimObjQueueCallable to the queue given a processing-time interval. When the SimObjQueueCallable is scheduled and the corresponding event is processed, its call() method will be executed.
      Parameters:
      callable - the SimObjQueueCallable to add
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      Returns:
      the SimulationEvent created; null if the QueueCallable cannot be queued
    • add

      public SimulationEvent add(SimObjQueueCallable<QS> callable, long delay, double tpriority)
      Add a SimObjQueueCallable to the queue given a processing-time interval and a time event priority. When the SimObjQueueCallable is scheduled and the corresponding event is processed, its call() method will be executed.
      Parameters:
      callable - the SimObjQueueCallable to add
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      tpriority - the time event priority
      Returns:
      the SimulationEvent created; null if the QueueCallable cannot be queued
    • addCallObject

      public SimulationEvent addCallObject(Object scriptObject, long delay)
      Queue an event providing a script object given a processing-time interval. This should be called by a subclass to add an event to a queue, as the currently scheduled event is handled specially. The subclass is responsible for using its "add" method's arguments to construct an instance of type T. The method's first argument is an object defined in the simulation's scripting language that implements two methods: an interactWith method that takes a server as an argument (the server's type is set by the type parameter QS) and a call method that has no arguments. The interactWith method will be called first, followed by the call method.
      Parameters:
      scriptObject - the object specifying the task to be queued
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      Returns:
      the SimulationEvent created; null if the QueueCallable cannot be queued
    • addCallObject

      public SimulationEvent addCallObject(Object scriptObject, long delay, double tpriority)
      Queue an event providing a script object given a processing-time interval and time event priority. This should be called by a subclass to add an event to a queue, as the currently scheduled event is handled specially. The subclass is responsible for using its "add" method's arguments to construct an instance of type T. The method's first argument is an object defined in the simulation's scripting language that implements two methods: an interactWith method that takes a server as an argument (the server's type is set by the type parameter QS) and a call method that has no arguments. The interactWith method will be called first, followed by the call method.
      Parameters:
      scriptObject - the object specifying the task to be queued
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      tpriority - the time event priority
      Returns:
      the SimulationEvent created; null if the QueueCallable cannot be queued
    • add

      public SimulationEvent add(QueueRunnable<QS> runnable, long delay)
      Add a QueueRunnable to the queue given a processing-time interval. When the QueueRunnable is scheduled and the corresponding event is processed, a task thread will be started executing the Runnable. Task threads and the simulation's thread run one at a time, including on a multiprocessor.
      Parameters:
      runnable - the QueueRunnable to add to the queue
      delay - the interval between when runnable is scheduled to be started and when it is actually started, representing the service time for this queue entry.
      Returns:
      the SimulationEvent created; null if the QueueRunnable cannot be queued
    • add

      public SimulationEvent add(QueueRunnable<QS> runnable, long delay, double tpriority)
      Add a QueueRunnable to the queue given a processing-time interval and time event priority. When the QueueRunnable is scheduled and the corresponding event is processed, a task thread will be started executing the Runnable. Task threads and the simulation's thread run one at a time, including on a multiprocessor.
      Parameters:
      runnable - the QueueRunnable to add to the queue
      delay - the interval between when runnable is scheduled to be started and when it is actually started, representing the service time for this queue entry.
      tpriority - the time event priority
      Returns:
      the SimulationEvent created; null if the QueueRunnable cannot be queued
    • add

      public SimulationEvent add(SimObjQueueRunnable<QS> runnable, long delay)
      Add a SimObjQueueRunnable to the queue given a processing-time interval. When the SimObjQueueRunnable is scheduled and the corresponding event is processed, a task thread will be started executing the Runnable. Task threads and the simulation's thread run one at a time, including on a multiprocessor.
      Parameters:
      runnable - the SimObjQueueRunnable to add to the queue
      delay - the interval between when runnable is scheduled to be started and when it is actually started, representing the service time for this queue entry.
      Returns:
      the SimulationEvent created; null if the QueueRunnable cannot be queued
    • add

      public SimulationEvent add(SimObjQueueRunnable<QS> runnable, long delay, double tpriority)
      Add a SimObjQueueRunnable to the queue given a processing-time interval and time event priority. When the SimObjQueueRunnable is scheduled and the corresponding event is processed, a task thread will be started executing the Runnable. Task threads and the simulation's thread run one at a time, including on a multiprocessor.
      Parameters:
      runnable - the SimObjQueueRunnable to add to the queue
      delay - the interval between when runnable is scheduled to be started and when it is actually started, representing the service time for this queue entry.
      tpriority - the time event priority
      Returns:
      the SimulationEvent created; null if the QueueRunnable cannot be queued
    • addTaskObject

      public SimulationEvent addTaskObject(Object scriptObject, long delay)
      Queue an event given a script object that provides QueueRunnable interface and given a processing-time interval. The script object must implement a method named interactWith that takes a QueueServer as its argument and a method with no arguments named run, which will be executed in that order in a task thread.
      Parameters:
      scriptObject - the script object defining the task and its interaction with a server
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      Returns:
      the SimulationEvent created; null if the QueueRunnable cannot be queued
    • addTaskObject

      public SimulationEvent addTaskObject(Object scriptObject, long delay, double tpriority)
      Queue an event given a script object that provides QueueRunnable interface and given a processing-time interval and time event priority. The script object must implement a method named interactWith that takes a QueueServer as its argument and a method with no arguments named run, which will be executed in that order in a task thread.
      Parameters:
      scriptObject - the script object defining the task and its interaction with a server
      delay - the interval between when callable is scheduled to be called and when it is actually called, representing the service time for this queue entry.
      tpriority - the time event priority
      Returns:
      the SimulationEvent created; null if the QueueRunnable cannot be queued
    • addCurrentTask

      public boolean addCurrentTask(QueueServerHandler<QS> handler, long delay)
      Add the currently running task thread to a queue given a processing-time interval.
      Parameters:
      handler - the handler whose interactWith method will be called with a queue server as its argument when the queue server handles the queue entry being processed
      delay - the delay to wait before the task is restarted once scheduled.
      Returns:
      true on success; false if the task cannot be placed on the queue
    • addCurrentTask

      public boolean addCurrentTask(QueueServerHandler<QS> handler, long delay, double tpriority)
      Add the currently running task thread to a queue given a processing-time interval and time event priority.
      Parameters:
      handler - the handler whose interactWith method will be called with a queue server as its argument when the queue server handles the queue entry being processed
      delay - the delay to wait before the task is restarted once scheduled.
      tpriority - the time event priority
      Returns:
      true on success; false if the task cannot be placed on the queue
    • addCurrentTaskScriptObject

      public boolean addCurrentTaskScriptObject(Object scriptObject, long delay)
      Add the currently running task thread to a queue, specifying a script object to implement the QueueServerHandler interface and given a processing-time interval. The script object must implement a method named interactWith that takes a single argument, a QueueServer, and this method will be called before the task resumes.
      Parameters:
      scriptObject - the script object specifying the task to be queued.
      delay - the delay to wait before the task is restarted once scheduled.
      Returns:
      true if the task was restarted by the queue; false if it was canceled or could not be queued
    • addCurrentTaskScriptObject

      public boolean addCurrentTaskScriptObject(Object scriptObject, long delay, Object scriptSimEventCallable)
      Add the currently running task thread to a queue, specifying a script object to implement the QueueServerHandler interface and given a processing-time interval. The script object must implement a method named interactWith that takes a single argument, a QueueServer, and this method will be called before the task resumes. The scriptSimEventCallable argument is an object that implements a method named call that takes a single argument, a SimulationEvent. Typically this argument will be stored in case it is necessary to remove the task from the queue and restart it.
      Parameters:
      scriptObject - the script object specifying the task to be queued.
      delay - the delay to wait before the task is restarted once scheduled.
      scriptSimEventCallable - an object in a scripting language representing a SimEventCallable
      Returns:
      true if the task was restarted by the queue; false if it was canceled or could not be queued
    • addCurrentTaskScriptObject

      public boolean addCurrentTaskScriptObject(Object scriptObject, long delay, double tpriority)
      Add the currently running task thread to a queue, specifying a script object to implement the QueueServerHandler interface and given a processing-time interval and time event priority. The script object must implement a method named interactWith that takes a single argument, a QueueServer, and this method will be called before the task resumes.
      Parameters:
      scriptObject - the script object specifying the task to be queued.
      delay - the delay to wait before the task is restarted once scheduled.
      tpriority - the time event priority
      Returns:
      true if the task was restarted by the queue; false if it was canceled or could not be queued
    • addCurrentTaskScriptObject

      public boolean addCurrentTaskScriptObject(Object scriptObject, long delay, double tpriority, Object scriptSimEventCallable)
      Add the currently running task thread to a queue, specifying a script object to implement the QueueServerHandler interface and given a processing-time interval and time event priority in addition to an object implementing the SimEventCallable interface. The script object must implement a method named interactWith that takes a single argument, a QueueServer, and this method will be called before the task resumes. The scriptSimEventCallable argument is an object that implements a method named call that takes a single argument, a SimulationEvent. Typically this argument will be stored in case it is necessary to remove the task from the queue and restart it.
      Parameters:
      scriptObject - the script object specifying the task to be queued.
      delay - the delay to wait before the task is restarted once scheduled.
      tpriority - the time event priority
      scriptSimEventCallable - the script object that obtains a SimulationEvent that can be used to remove the task from the queue
      Returns:
      true if the task was restarted by the queue; false if it was canceled or could not be queued
    • addCurrentTask

      public boolean addCurrentTask(long delay, double tpriority, SimEventCallable callable)
      Add the currently running task thread to a queue given a processing-time interval and time event priority.
      Parameters:
      delay - the delay to wait before the task is restarted once scheduled
      tpriority - the time event priority
      callable - this argument's call method will be run when the event is scheduled and will be passed a simulation event (e.g., to store the event to allow the event to be canceled)
      Returns:
      true on success; false if the task cannot be placed on the queue
    • addCurrentTask

      public boolean addCurrentTask(QueueServerHandler<QS> handler, long delay, SimEventCallable callable)
      Add the currently running task thread to a queue given a processing-time interval.
      Parameters:
      handler - the handler whose interactWith method will be called with a queue server as its argument when the queue server handles the queue entry being processed
      delay - the delay to wait before the task is restarted once scheduled.
      callable - this argument's call method will be run when the event is scheduled and will be passed a simulation event (e.g., to store the event to allow the event to be canceled)
      Returns:
      true on success; false if the task cannot be placed on the queue
    • addCurrentTask

      public boolean addCurrentTask(QueueServerHandler<QS> handler, long delay, double tpriority, SimEventCallable callable)
      Add the currently running task thread to a queue given a processing-time interval and time event priority.
      Parameters:
      handler - the handler whose interactWith method will be called with a queue server as its argument when the queue server handles the queue entry being processed
      delay - the delay to wait before the task is restarted once scheduled.
      tpriority - the time event priority
      callable - this argument's call method will be run when the event is scheduled and will be passed a simulation event (e.g., to store the event to allow the event to be canceled)
      Returns:
      true on success; false if the task cannot be placed on the queue
    • clone

      protected Object clone() throws CloneNotSupportedException
      Creates and returns a copy of this object. This method will throw the exception CloneNotSupportedException if the object is interned.
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException - a clone could not be created
      See Also:
    • isInterned

      public boolean isInterned()
      Determine if an object is interned in a object namer's tables.
      Specified by:
      isInterned in interface NamedObjectOps
      Returns:
      true if the object is interned; false if not
    • getObjectNamer

      protected Simulation getObjectNamer()
      Get the object namer for a named object.
      Returns:
      the object namer for this named object
    • getName

      public final String getName()
      Get an object's name.
      Specified by:
      getName in interface NamedObjectOps
      Returns:
      the name of the object
    • delete

      public final boolean delete()
      Delete an object. An object can only be deleted once. If this method returns true, the object (if interned) will have been removed from the object namer tables.

      The implementations provided by DefaultNamedObect and generated because of a @NamedObject annotation provide a protected method named onDelete. A subclass that overrides onDelete() must call the onDelete method of its superclass after it's onDelete method has been called and any cleanup actions performed. In some cases, this may happen at a later time (e.g., if a thread is used for some of the cleanup operations or if it is otherwise necessary to wait).

      Specified by:
      delete in interface NamedObjectOps
      Returns:
      true if the deletion request was accepted; false otherwise
    • isDeleted

      public final boolean isDeleted()
      Determine if an object has been deleted. An object is deleted if the method delete() has been called and returned true.
      Specified by:
      isDeleted in interface NamedObjectOps
      Returns:
      true if deleted; false otherwise
    • deletePending

      public final boolean deletePending()
      Determine if an object is being deleted. An deletion is pending if the method delete() has been called and returned true but the deletion has not been completed.
      Specified by:
      deletePending in interface NamedObjectOps
      Returns:
      true if deletion is pending; false otherwise