Пример #1
0
        public void SerializedMessageReceived(SerializedMessage serializedMessage, ReturnAddress from)
        {
            System.Diagnostics.Debug.Assert(this.AvailableEntrancy >= -1);
            if (this.decoder == null)
            {
                this.decoder = new AutoSerializedMessageDecoder <S, T>(this.Vertex.SerializationFormat);
            }

            if (this.loggingEnabled)
            {
                this.LogMessage(serializedMessage);
            }

            Message <S, T> msg = new Message <S, T>();

            msg.Allocate(AllocationReason.Deserializer);
            // N.B. At present, AsTypedMessages reuses and yields the same given msg for each batch
            //      of deserialized messages. As a result, the message passed to OnReceive MUST NOT
            //      be queued, because its payload will be overwritten by the next batch of messages.
            foreach (Message <S, T> message in this.decoder.AsTypedMessages(serializedMessage, msg))
            {
                this.OnReceive(message, from);
            }
            msg.Release(AllocationReason.Deserializer);
        }
Пример #2
0
            public Mailbox(PostOffice postOffice, Runtime.Progress.ProgressUpdateCentralizer consumer, int id, int vertexId)
            {
                this.postOffice = postOffice;
                this.consumer   = consumer;
                this.id         = id;
                this.vertexId   = vertexId;
                this.graphId    = this.consumer.Stage.InternalComputation.Index;

                this.decoder = new AutoSerializedMessageDecoder <Update, Empty>(consumer.SerializationFormat);
            }
Пример #3
0
 public void SerializedMessageReceived(SerializedMessage message, RemotePostbox sender)
 {
     if (this.decoder == null)
     {
         this.decoder = new AutoSerializedMessageDecoder <TRecord, TTime>();
     }
     foreach (Pair <TRecord, TTime> record in this.decoder.Elements(message))
     {
         this.RecordReceived(record, sender);
     }
 }
Пример #4
0
        public void SerializedMessageReceived(SerializedMessage serializedMessage, RemotePostbox sender)
        {
            if (this.decoder == null)
            {
                this.decoder = new AutoSerializedMessageDecoder <S, T>(this.Vertex.CodeGenerator);
            }

            foreach (Message <S, T> message in this.decoder.AsTypedMessages(serializedMessage))
            {
                this.MessageReceived(message, sender);
                message.Release();
            }
        }
Пример #5
0
            public Mailbox(PostOffice postOffice, Runtime.Progress.ProgressUpdateConsumer consumer, int id, int vertexId, int numProducers)
            {
                this.postOffice = postOffice;
                this.consumer   = consumer;
                this.graphid    = this.consumer.Stage.InternalComputation.Index;

                this.id       = id;
                this.vertexId = vertexId;

                this.nextSequenceNumbers = new int[numProducers];

                this.decoder = new AutoSerializedMessageDecoder <Update, Empty>(consumer.SerializationFormat);
            }
Пример #6
0
        /// <summary>
        /// Buffers the content of the given <paramref name="serializedMessage"/>, and
        /// schedules a corresponding notification on the owning <see cref="Vertex"/>.
        /// </summary>
        /// <param name="serializedMessage">The serialized message.</param>
        /// <param name="sender">The sender of the message.</param>
        public void SerializedMessageReceived(SerializedMessage serializedMessage, ReturnAddress sender)
        {
            System.Diagnostics.Debug.Assert(this.AvailableEntrancy >= -1);
            if (this.decoder == null)
            {
                this.decoder = new AutoSerializedMessageDecoder <TRecord, TTime>(this.Vertex.SerializationFormat);
            }

            foreach (Message <TRecord, TTime> message in this.decoder.AsTypedMessages(serializedMessage))
            {
                this.OnReceive(message, sender);
                message.Release();
            }
        }
Пример #7
0
        public LegacyLocalMailbox(PostOffice postOffice, VertexInput <S, T> endpoint, int id, int vertexId)
            : base(postOffice, endpoint, id, vertexId)
        {
            this.sharedQueue           = new ConcurrentQueue <Message <S, T> >();
            this.sharedSerializedQueue = new ConcurrentQueue <SerializedMessage>();
            this.privateQueue          = new Queue <Message <S, T> >();

            this.messagesFromLocalVertices = new Message <S, T> [this.postOffice.Controller.Workers.Count];
            for (int i = 0; i < this.postOffice.Controller.Workers.Count; ++i)
            {
                this.messagesFromLocalVertices[i] = new Message <S, T>();
            }

            this.decoder = new AutoSerializedMessageDecoder <S, T>(endpoint.Vertex.SerializationFormat);
        }
Пример #8
0
        public void SerializedMessageReceived(SerializedMessage serializedMessage, ReturnAddress from)
        {
            System.Diagnostics.Debug.Assert(this.AvailableEntrancy >= -1);
            if (this.decoder == null)
            {
                this.decoder = new AutoSerializedMessageDecoder <S, T>(this.Vertex.SerializationFormat);
            }

            if (this.loggingEnabled)
            {
                this.LogMessage(serializedMessage);
            }

            foreach (Message <S, T> message in this.decoder.AsTypedMessages(serializedMessage))
            {
                this.OnReceive(message, from);
                message.Release();
            }
        }
Пример #9
0
        public void SerializedMessageReceived(SerializedMessage message, RemotePostbox from)
        {
            System.Diagnostics.Debug.Assert(this.AvailableEntrancy >= -1);
            if (this.decoder == null)
            {
                this.decoder = new AutoSerializedMessageDecoder <S, T>();
            }

            if (this.loggingEnabled)
            {
                this.LogMessage(message);
            }
            foreach (Pair <S, T> record in this.decoder.Elements(message))
            {
                this.Buffer.payload[this.Buffer.length++] = record;
                if (this.Buffer.length == this.Buffer.payload.Length)
                {
                    var temp = Buffer;
                    Buffer.Disable();

                    if (SpareBuffers.Count > 0)
                    {
                        Buffer = SpareBuffers.Dequeue();
                    }
                    else
                    {
                        Buffer.Enable();
                    }

                    this.MessageReceived(temp, from);

                    temp.length = 0;
                    SpareBuffers.Enqueue(temp);

                    System.Diagnostics.Debug.Assert(this.Buffer.length == 0);
                    //this.Buffer.length = 0;
                }
            }

            if (this.Buffer.length > 0)
            {
                var temp = Buffer;
                Buffer.Disable();

                if (SpareBuffers.Count > 0)
                {
                    Buffer = SpareBuffers.Dequeue();
                }
                else
                {
                    Buffer.Enable();
                }

                this.MessageReceived(temp, from);

                temp.length = 0;
                SpareBuffers.Enqueue(temp);

                System.Diagnostics.Debug.Assert(this.Buffer.length == 0);
                //this.Buffer.length = 0;
            }
        }