Exemplo n.º 1
0
 /// <summary>
 /// Invokes the specified monitor with the given event.
 /// </summary>
 /// <typeparam name="T">Type of the monitor</typeparam>
 /// <param name="e">Event</param>
 /// <param name="payload">Optional payload</param>
 protected internal void Monitor <T>(Event e, params Object[] payload)
 {
     // If the event is null then report an error and exit.
     this.Assert(e != null, "Machine '{0}' is sending a null event.", this.GetType().Name);
     e.AssignPayload(payload);
     Machine.Dispatcher.Monitor <T>(e);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Sends an asynchronous event to a machine.
 /// </summary>
 /// <param name="target">Target machine id</param>
 /// <param name="e">Event</param>
 /// <param name="payload">Optional payload</param>
 public static void SendEvent(MachineId target, Event e, params Object[] payload)
 {
     // If the event is null then report an error and exit.
     PSharpRuntime.Assert(e != null, "Cannot send a null event.");
     e.AssignPayload(payload);
     PSharpRuntime.Send(target, e);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Invokes the specified monitor with the given event.
 /// </summary>
 /// <typeparam name="T">Type of the monitor</typeparam>
 /// <param name="e">Event</param>
 /// <param name="payload">Optional payload</param>
 public static void InvokeMonitor <T>(Event e, params Object[] payload)
 {
     // If the event is null then report an error and exit.
     PSharpRuntime.Assert(e != null, "Cannot send a null event.");
     e.AssignPayload(payload);
     PSharpRuntime.Monitor <T>(e);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Raises an event internally and returns from the execution context.
 /// </summary>
 /// <param name="e">Event</param>
 /// <param name="payload">Optional payload</param>
 protected internal void Raise(Event e, params Object[] payload)
 {
     // If the event is null then report an error and exit.
     this.Assert(e != null, "Machine '{0}' is raising a null event.", this.GetType().Name);
     e.AssignPayload(payload);
     Machine.Dispatcher.Log("<RaiseLog> Machine '{0}({1})' raised event '{2}'.", this, base.Id.MVal, e);
     this.RaisedEvent = e;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Raises an event internally and returns from the execution context.
 /// </summary>
 /// <param name="e">Event</param>
 /// <param name="payload">Optional payload</param>
 protected internal void Raise(Event e, params Object[] payload)
 {
     // If the event is null then report an error and exit.
     this.Assert(e != null, "Monitor '{0}' is raising a null event.", this.GetType().Name);
     e.AssignPayload(payload);
     Machine.Dispatcher.Log("<MonitorLog> Monitor '{0}' raised event '{1}'.", this, e);
     this.HandleEvent(e);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Raises an event internally and returns from the execution context.
        /// </summary>
        /// <param name="e">Event</param>
        /// <param name="payload">Optional payload</param>
        protected internal void Raise(Event e, params Object[] payload)
        {
            // If the event is null then report an error and exit.
            this.Assert(e != null, "Monitor '{0}' is raising a null event.", this.GetType().Name);

            e.AssignPayload(payload);
            Output.Debug(DebugType.Runtime, "<RaiseLog> Monitor '{0}' " +
                         "raised event '{1}'.", this, e);
            this.HandleEvent(e);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Raises an event internally and returns from the execution context.
        /// </summary>
        /// <param name="e">Event</param>
        /// <param name="payload">Optional payload</param>
        protected internal void Raise(Event e, params Object[] payload)
        {
            // If the event is null then report an error and exit.
            this.Assert(e != null, "Machine '{0}' is raising a null event.", this.GetType().Name);

            e.AssignPayload(payload);
            Output.Debug(DebugType.Runtime, "<RaiseLog> Machine '{0}({1})' raised " +
                         "event '{2}'.", this, this.Id.MVal, e);
            this.RaisedEvent = e;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Sends an asynchronous event to a machine.
        /// </summary>
        /// <param name="m">Machine id</param>
        /// <param name="e">Event</param>
        /// <param name="payload">Optional payload</param>
        protected internal void Send(MachineId mid, Event e, params Object[] payload)
        {
            // If the event is null then report an error and exit.
            this.Assert(e != null, "Machine '{0}' is sending a null event.", this.GetType().Name);

            e.AssignPayload(payload);
            Output.Debug(DebugType.Runtime, "<SendLog> Machine '{0}({1})' sent event '{2}' " +
                         "to '{3}({4})'.", this, this.Id.MVal, e.GetType(), mid.Type, mid.MVal);
            Machine.Dispatcher.Send(mid, e);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Sends an asynchronous event to a machine.
        /// </summary>
        /// <param name="target">Target machine id</param>
        /// <param name="e">Event</param>
        /// <param name="payload">Optional payload</param>
        public static void SendEvent(MachineId target, Event e, params Object[] payload)
        {
            e.AssignPayload(payload);

            try
            {
                PSharpRuntime.Send(target, e);
            }
            catch (TaskCanceledException)
            {
                Output.Log("<Exception> TaskCanceledException was thrown.");
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sends an asynchronous event to a machine.
        /// </summary>
        /// <param name="target">Target machine id</param>
        /// <param name="e">Event</param>
        /// <param name="payload">Optional payload</param>
        public static void SendEvent(MachineId target, Event e, params Object[] payload)
        {
            // If the event is null then report an error and exit.
            PSharpRuntime.Assert(e != null, "Cannot send a null event.");
            e.AssignPayload(payload);

            try
            {
                PSharpRuntime.Send(target, e);
            }
            catch (TaskCanceledException)
            {
                Output.Debug("<Exception> TaskCanceledException was thrown.");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Raises an event internally and returns from the execution context.
        /// </summary>
        /// <param name="e">Event</param>
        /// <param name="payload">Optional payload</param>
        protected internal void Raise(Event e, params Object[] payload)
        {
            // If the event is null then report an error and exit.
            this.Assert(e != null, "Monitor '{0}' is raising a null event.", this.GetType().Name);

            e.AssignPayload(payload);
            Output.Debug(DebugType.Runtime, "<RaiseLog> Monitor '{0}' " +
                "raised event '{1}'.", this, e);
            this.HandleEvent(e);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Sends an asynchronous event to a machine.
 /// </summary>
 /// <param name="target">Target machine id</param>
 /// <param name="e">Event</param>
 /// <param name="payload">Optional payload</param>
 public static void SendEvent(MachineId target, Event e, params Object[] payload)
 {
     e.AssignPayload(payload);
     PSharpRuntime.Send(target, e);
 }