Example #1
0
        /// <summary>
        /// First-round follow-on to the <see cref="Initialize"/> call.
        /// </summary>
        /// <param name="model">The model in which this queue exists.</param>
        /// <param name="p">The array of passed-in arguments.</param>
        public void _Initialize(IModel model, object[] p)
        {
            Guid inGuid  = Utility.GuidOps.Increment(Guid);
            Guid outGuid = Utility.GuidOps.Increment(inGuid);

            m_output = new SimpleOutputPort(model, "Output", outGuid, this, new DataProvisionHandler(ProvideData), new DataProvisionHandler(PeekData));
            m_output.PortDataAccepted += new PortDataEvent(OnOutputPortDataAccepted);
            m_input = new SimpleInputPort(model, "Input", inGuid, this, new DataArrivalHandler(OnDataArrived));

            //Ports.AddPort(m_output); <-- Done in port's ctor.
            //Ports.AddPort(m_input);  <-- Done in port's ctor.

            LevelChangedEvent += new QueueLevelChangeEvent(OnQueueLevelChanged);

            m_max   = (int)p[0];
            m_queue = new System.Collections.Queue(m_max);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Queue"/> class.
        /// </summary>
        /// <param name="model">The model in which this queue exists.</param>
        /// <param name="name">The name of this queue.</param>
        /// <param name="guid">The GUID of this queue.</param>
        /// <param name="max">The maximum number of items that can be held in this queue.</param>
        public Queue(IModel model, string name, Guid guid, int max)
        {
            InitializeIdentity(model, name, "", guid);
            m_max = max;

            m_queue = new System.Collections.Queue();

            Guid inGuid  = Utility.GuidOps.Increment(guid);
            Guid outGuid = Utility.GuidOps.Increment(inGuid);

            m_output = new SimpleOutputPort(model, "Output", outGuid, this, new DataProvisionHandler(ProvideData), new DataProvisionHandler(PeekData));
            m_output.PortDataAccepted += new PortDataEvent(OnOutputPortDataAccepted);
            m_input = new SimpleInputPort(model, "Input", inGuid, this, new DataArrivalHandler(OnDataArrived));

            LevelChangedEvent += new QueueLevelChangeEvent(OnQueueLevelChanged);

            IMOHelper.RegisterWithModel(this);
        }
Example #3
0
 public OldestShortestQueueStrategy()
 {
     m_qlce = new QueueLevelChangeEvent(OnQueueLevelChanged);
 }