simpype.queue
¶
SimPype’s queue.
-
class
simpype.queue.
Queue
(sim, pipe, id)¶ Queue is used by
Pipe
to storeMessage
objects.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.
Infinite
by default.Type: int
-
active
¶ Event signaling when the queue is active.
Type: simpy.events.Event
-
disable
()¶ Disable this queue by resetting the
active
attribute.
-
enable
()¶ Enable this queue by triggering the
active
attribute.
- sim (
-
simpype.queue.
pop
(arg)¶ Decorator for overloading the default
Queue
pop behavior.Parameters: arg ( Queue
)(self
) – TheQueue
instance.If the overloading is done in scripts, the
Queue
instance 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.
Queue
instance 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
Queue
push behavior.Parameters: arg ( Queue
)(self
) – TheQueue
instance.If the overloading is done in scripts, the
Queue
instance 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.
Queue
instance 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