# Path: pif_ir/air/objects/processor.py
# class ThreadedProcessor(Thread, Processor):
#     """
#     @brief Base class for threaded processor types
# 
#     Provides the base class for a processor which supports its own
#     thread context for processing and producing packets.
# 
#     The threaded_processor.process() function enqueues the passed
#     packet into its own queue for processing in its own thread
#     context. That is done by the _process() function which must be
#     implemented by the super class.
# 
#     Because of this decoupling, the consumer of the packets produced
#     by this processor must be plumbed. Currently the only support for
#     this connectivity is by registering a consumer for packets produced
#     by the processor.
# 
#     POR: To support more flexible composition of processor
#     composition, the plan is to allow the packet to store the 
#     "next processor", essentially as metadata.
# 
#     @todo The implementation is not really relevant and should probably be removed
#     """
# 
#     def __init__(self, name, max_queue_size=0):
#         """
#         @param name The name of the processor object
#         @param max_queue_size Queue will block if max_queue_size is reached
#         """
#         Thread.__init__(self)
#         Processor.__init__(self, name)
#         self.next_processor = None
# 
#         self.max_queue_size = max_queue_size
#         self.queue = Queue(max_queue_size)
#         self.running = True
# 
#     def process(self, parsed_packet):
#         """
#         @param parsed_packet The packet to process
# 
#         See Processor base class. 
# 
#         The default behavior is to enqueue the packet passed for processing 
#         in this objects thread context
# 
#         May be overridden by super class to do a different
#         processing model (alternative queuing)
#         """
#         self.queue.put(parsed_packet, block=True, timeout=None)
# 
#     def run(self):
#         """
#         Activity function for class
#         """
#         while True:
#             pkt = self.queue.get()
#             if self.running:
#                 self._process(pkt)
# 
#     def kill(self):
#         self.running = False
#         self.queue.join()
# 
#     def _process(self, parsed_packet):
#         """
#         Should not be called. The sub class must implement _process()
#         """
#         raise AirImplementationError("Processor %s: Super class %s " %
#             (self.name, str(type(self))) + "of threaded_processor does "
#             "not implement _process")


import threading
import sys
from pif_ir.meta_ir.common import *
from pif_ir.air.objects.processor import ThreadedProcessor
    from parsed_packet import ParsedPacket
#!/usr/bin/env python
# Simple queuing module



class SimpleQueueManager(ThreadedProcessor):
    """
    @brief Manage a bunch of queues, support replication
    @param name The name of the TM object
    @param meta_ir_traffic_manager_attrs The  MetaIR TM attributes
    @param port_count The number of ports to support
    @param next_processor The next packet processor function to call

    This simple queue manager uses the threading of ThreadedProcessor
    to provide post-dequeue processing to have a thread context (this
    object's context).

    When the process() method is called, the calculation of the
    proper queue in which to submit the packet(s) is made and
    copying, etc, is done in that thread context. Then the queue's
    thread is invoked and does the dequeuing.

    Currently supports only strict priority (max is highest)
    """
    def __init__(self, name, meta_ir_traffic_manager_attrs, port_count):

# Path: pif_ir/air/objects/processor.py
# class ThreadedProcessor(Thread, Processor):
#     """
#     @brief Base class for threaded processor types
# 
#     Provides the base class for a processor which supports its own
#     thread context for processing and producing packets.
# 
#     The threaded_processor.process() function enqueues the passed
#     packet into its own queue for processing in its own thread
#     context. That is done by the _process() function which must be
#     implemented by the super class.
# 
#     Because of this decoupling, the consumer of the packets produced
#     by this processor must be plumbed. Currently the only support for
#     this connectivity is by registering a consumer for packets produced
#     by the processor.
# 
#     POR: To support more flexible composition of processor
#     composition, the plan is to allow the packet to store the 
#     "next processor", essentially as metadata.
# 
#     @todo The implementation is not really relevant and should probably be removed
#     """
# 
#     def __init__(self, name, max_queue_size=0):
#         """
#         @param name The name of the processor object
#         @param max_queue_size Queue will block if max_queue_size is reached
#         """
#         Thread.__init__(self)
#         Processor.__init__(self, name)
#         self.next_processor = None
# 
#         self.max_queue_size = max_queue_size
#         self.queue = Queue(max_queue_size)
#         self.running = True
# 
#     def process(self, parsed_packet):
#         """
#         @param parsed_packet The packet to process
# 
#         See Processor base class. 
# 
#         The default behavior is to enqueue the packet passed for processing 
#         in this objects thread context
# 
#         May be overridden by super class to do a different
#         processing model (alternative queuing)
#         """
#         self.queue.put(parsed_packet, block=True, timeout=None)
# 
#     def run(self):
#         """
#         Activity function for class
#         """
#         while True:
#             pkt = self.queue.get()
#             if self.running:
#                 self._process(pkt)
# 
#     def kill(self):
#         self.running = False
#         self.queue.join()
# 
#     def _process(self, parsed_packet):
#         """
#         Should not be called. The sub class must implement _process()
#         """
#         raise AirImplementationError("Processor %s: Super class %s " %
#             (self.name, str(type(self))) + "of threaded_processor does "
#             "not implement _process")


# Path: pif_ir/air/objects/simple_queue.py
import threading
import sys
from pif_ir.meta_ir.common import *
from pif_ir.air.objects.processor import ThreadedProcessor
    from parsed_packet import ParsedPacket

#!/usr/bin/env python
# Simple queuing module



class SimpleQueueManager(ThreadedProcessor):
    """
    @brief Manage a bunch of queues, support replication
    @param name The name of the TM object
    @param meta_ir_traffic_manager_attrs The  MetaIR TM attributes
    @param port_count The number of ports to support
    @param next_processor The next packet processor function to call

    This simple queue manager uses the threading of ThreadedProcessor
    to provide post-dequeue processing to have a thread context (this
    object's context).

    When the process() method is called, the calculation of the
    proper queue in which to submit the packet(s) is made and
    copying, etc, is done in that thread context. Then the queue's
    thread is invoked and does the dequeuing.

    Currently supports only strict priority (max is highest)
    """
    def __init__(self, name, meta_ir_traffic_manager_attrs, port_count):

        ThreadedProcessor.__init__(self, name)