locked
RequestValue Keyword? RRS feed

  • Question

  • The following code compiles:

    using System;
    using Microsoft.Axum;
    using System.Concurrency.Messaging;
    
    namespace Project06
    {
      schema Pair
    	{
        required int Num1;
        required int Num2;
    	}
      
      channel Adder
    	{
        input Pair Nums : int;
      }
      
    	agent AdderAgent : channel Adder
    	{
    		public AdderAgent()
    		{
          while(true)
          {
            var result = receive(PrimaryChannel::Nums);
            result <-- result.RequestValue.Num1 + result.RequestValue.Num2;
          }
    		}
    	}
    
      agent MainAgent : channel Microsoft.Axum.Application
      {
        public MainAgent()
        {
          var adder = AdderAgent.CreateInNewDomain();
          var correlator1 = adder::Nums <-- new Pair { Num1=10, Num2=20 };
          var correlator2 = adder::Nums <-- new Pair { Num1=30, Num2=40 };
          var sum1 = receive(correlator1);
          Console.WriteLine(sum1);
          var sum2 = receive(correlator2);
          Console.WriteLine(sum2);
          PrimaryChannel::ExitCode <-- 0;
        }
      }
    }
    
    

    I am wondering about the syntax in the AdderAgent; specifically, the following line:

    result <-- result.RequestValue.Num1 + result.RequestValue.Num2;
    

    Is "RequestValue" an Axum keyword? I didn't define it in the application, but I also don't see it in the language spec. Also, how am I allowed to send a value to "result" although I haven't defined an output variable in the channel?

    Sunday, August 22, 2010 11:03 PM

Answers

  • What happens with request / reply (duplex) ports is that the message that you actually receive from it (the request) is a class containing:

    a) the incoming data, in RequestValue

    b) a special target to send the reply to, unique to this particular request

    The latter is how come we can correlate each request with its corresponding reply. On the sending side, the result of the send expression is similarly a special source that you receive the unique reply from. This means that you can have multiple outstanding requests and still match requests and replies without having to send along  UUIDs in the messages or do some other ad hoc correlation.

    Niklas

    Friday, September 3, 2010 1:38 AM
    Moderator

All replies

  • RequestValue looks like a property of Signal.
    Wednesday, September 1, 2010 10:55 AM
  • What happens with request / reply (duplex) ports is that the message that you actually receive from it (the request) is a class containing:

    a) the incoming data, in RequestValue

    b) a special target to send the reply to, unique to this particular request

    The latter is how come we can correlate each request with its corresponding reply. On the sending side, the result of the send expression is similarly a special source that you receive the unique reply from. This means that you can have multiple outstanding requests and still match requests and replies without having to send along  UUIDs in the messages or do some other ad hoc correlation.

    Niklas

    Friday, September 3, 2010 1:38 AM
    Moderator