internal void SendStop(ZObject destination) { // 'stop' command goes always from administrative thread to // the current object. Command cmd = new Command(destination, CommandType.Stop); SendCommand(cmd); }
/// <summary> /// Create a new Pipe object with the given parent, and inbound and outbound YPipes. /// </summary> /// <remarks> /// Constructor is private as pipe can only be created using <see cref="PipePair"/> method. /// </remarks> private Pipe( [NotNull] ZObject parent, [NotNull] YPipe <Msg> inboundPipe, [NotNull] YPipe <Msg> outboundPipe, int inHighWatermark, int outHighWatermark, int predefinedLowWatermark) : base(parent) { m_parent = parent; m_inboundPipe = inboundPipe; m_outboundPipe = outboundPipe; m_inActive = true; m_outActive = true; m_highWatermark = outHighWatermark; m_lowWatermark = ComputeLowWatermark(inHighWatermark, predefinedLowWatermark); m_numberOfMessagesRead = 0; m_numberOfMessagesWritten = 0; m_peersMsgsRead = 0; m_peer = null; m_sink = null; m_state = State.Active; m_delay = true; }
/// <summary> /// Create a new ZObject that has the same context and thread-id as the given parent-ZObject. /// </summary> /// <param name="parent">another ZObject that provides the context and thread-id for this one</param> protected ZObject([NotNull] ZObject parent) : this(parent.m_ctx, parent.m_threadId) { }
/// <summary> /// Create a new Pipe object with the given parent, and inbound and outbound YPipes. /// </summary> /// <remarks> /// Constructor is private as pipe can only be created using <see cref="PipePair"/> method. /// </remarks> private Pipe( [NotNull] ZObject parent, [NotNull] YPipe<Msg> inboundPipe, [NotNull] YPipe<Msg> outboundPipe, int inHighWatermark, int outHighWatermark, int predefinedLowWatermark, bool delay) : base(parent) { m_parent = parent; m_inboundPipe = inboundPipe; m_outboundPipe = outboundPipe; m_inActive = true; m_outActive = true; m_highWatermark = outHighWatermark; m_lowWatermark = ComputeLowWatermark(inHighWatermark, predefinedLowWatermark); m_numberOfMessagesRead = 0; m_numberOfMessagesWritten = 0; m_peersMsgsRead = 0; m_peer = null; m_sink = null; m_state = State.Active; m_delay = delay; }
/// <summary> /// Create a new ZObject that has the same context and thread-id as the given parent-ZObject. /// </summary> /// <param name="parent">another ZObject that provides the context and thread-id for this one</param> protected ZObject(ZObject parent) : this(parent.m_ctx, parent.m_threadId) { }
/// <summary> /// Create a pipe pair for bi-directional transfer of messages. /// </summary> /// <param name="parents">The parents.</param> /// <param name="highWaterMarks">First HWM is for messages passed from first pipe to the second pipe. /// Second HWM is for messages passed from second pipe to the first pipe.</param> /// <param name="delays">Delay specifies how the pipe behaves when the peer terminates. If true /// pipe receives all the pending messages before terminating, otherwise it /// terminates straight away.</param> /// <returns>A pipe pair for bi-directional transfer of messages. </returns> public static Pipe[] PipePair( ZObject[] parents, int[] highWaterMarks, bool[] delays) { // Creates two pipe objects. These objects are connected by two ypipes, // each to pass messages in one direction. var upipe1 = new YPipe<Msg>(Config.MessagePipeGranularity, "upipe1"); var upipe2 = new YPipe<Msg>(Config.MessagePipeGranularity, "upipe2"); var pipes = new[] { new Pipe(parents[0], upipe1, upipe2, highWaterMarks[1], highWaterMarks[0], delays[0]), new Pipe(parents[1], upipe2, upipe1, highWaterMarks[0], highWaterMarks[1], delays[1]) }; pipes[0].SetPeer(pipes[1]); pipes[1].SetPeer(pipes[0]); return pipes; }
/// <summary> /// Create a new ZObject that has the same context and thread-id as the given parent-ZObject. /// </summary> /// <param name="parent">another ZObject that provides the context and thread-id for this one</param> protected ZObject( ZObject parent) : this(parent.m_ctx, parent.m_threadId) {}
/// <summary> /// Create a new Command object for the given destination, type, and optional argument. /// </summary> /// <param name="destination">a ZObject that denotes the destination for this command</param> /// <param name="type">the CommandType of the new command</param> /// <param name="arg">an Object to comprise the argument for the command (optional)</param> public Command([CanBeNull] ZObject destination, CommandType type, [CanBeNull] object arg = null) : this() { Destination = destination; CommandType = type; Arg = arg; }