simpype.queue¶
SimPype’s queue.
-
class
simpype.queue.Queue(sim, pipe, id)¶ Queue is used by
Pipeto storeMessageobjects.Parameters: - sim (
Simulation) – The SimPype simulation object. - pipe (
Pipe) – The pipe this queue is associated to. - id (str) – The queue id.
-
sim¶ The SimPype simulation object.
Type: Simulation
-
env¶ The SimPy environment object.
Type: simpy.Environment
-
id¶ The queue id.
Type: str
-
capacity¶ The capacity of the buffer.
Infiniteby default.Type: int
-
active¶ Event signaling when the queue is active.
Type: simpy.events.Event
-
disable()¶ Disable this queue by resetting the
activeattribute.
-
enable()¶ Enable this queue by triggering the
activeattribute.
- sim (
-
simpype.queue.pop(arg)¶ Decorator for overloading the default
Queuepop behavior.Parameters: arg ( Queue)(self) – TheQueueinstance.If the overloading is done in scripts, the
Queueinstance must be provided as decorator argument.myresource = sim.add_resource(id = 'myresource') myresource.add_queue(id = 'myqueue') @simpype.queue.pop(myresource.pipe['myqueue']) def pop(self): return self.buffer.pop(0)
If the overloading is done inside a Queue subclass, the decorator must be called without any arguments.
Queueinstance is automatically provided throughself.class MyQueue(simpype.Queue): def __init__(self, sim, pipe, id): super().__init__(sim, pipe, id) @simpype.queue.pop def pop(self): return self.buffer.pop(0)
-
simpype.queue.push(arg)¶ Decorator for overloading the default
Queuepush behavior.Parameters: arg ( Queue)(self) – TheQueueinstance.If the overloading is done in scripts, the
Queueinstance must be provided as decorator argument.myresource = sim.add_resource(id = 'myresource') myresource.add_queue(id = 'myqueue') @simpype.queue.push(myresource.pipe['myqueue']) def push(self, message): self.buffer.append(message) return message
If the overloading is done inside a Queue subclass, the decorator must be called without any arguments.
Queueinstance is automatically provided throughself.class MyQueue(simpype.Queue): def __init__(self, sim, pipe, id): super().__init__(sim, pipe, id) @simpype.queue.push def push(self, message): self.buffer.append(message) return message