Defines a command sent between threads.
Esempio n. 1
0
        public void Send(Command command)
        {
            bool ok;
            lock (m_sync)
            {
                m_commandPipe.Write(ref command, false);
                ok = m_commandPipe.Flush();
            }

            if (!ok)
            {
                m_proactor.SignalMailbox(this);
            }
        }
Esempio n. 2
0
File: Ctx.cs Progetto: awb99/netmq
 /// <summary>
 /// Send a command to the given destination thread.
 /// </summary>
 public void SendCommand(int threadId,  Command command)
 {
     m_slots[threadId].Send(command);
 }
Esempio n. 3
0
 public bool TryReceive(TimeSpan timeout, out Command command)
 {
     return m_queue.TryTake(out command, timeout);
 }
Esempio n. 4
0
 public void Send(Command command)
 {
     m_queue.Add(command);
 }
Esempio n. 5
0
 internal static void SendCommand(int slotId, Command command)
 {
     s_slots[slotId].Send(command);
 }
Esempio n. 6
0
        public void ProcessCommand( Command cmd)
        {
            switch (cmd.CommandType)
            {
                case CommandType.ActivateRead:
                    ProcessActivateRead();
                    break;

                case CommandType.ActivateWrite:
                    ProcessActivateWrite((long)cmd.Arg);
                    break;

                case CommandType.Stop:
                    ProcessStop();
                    break;

                case CommandType.Plug:
                    ProcessPlug();
                    ProcessSeqnum();
                    break;

                case CommandType.Own:
                    ProcessOwn((Own)cmd.Arg);
                    ProcessSeqnum();
                    break;

                case CommandType.Attach:
                    ProcessAttach((IEngine)cmd.Arg);
                    ProcessSeqnum();
                    break;

                case CommandType.Bind:
                    ProcessBind((Pipe)cmd.Arg);
                    ProcessSeqnum();
                    break;

                case CommandType.Hiccup:
                    ProcessHiccup(cmd.Arg);
                    break;

                case CommandType.PipeTerm:
                    ProcessPipeTerm();
                    break;

                case CommandType.PipeTermAck:
                    ProcessPipeTermAck();
                    break;

                case CommandType.TermReq:
                    ProcessTermReq((Own)cmd.Arg);
                    break;

                case CommandType.Term:
                    ProcessTerm((int)cmd.Arg);
                    break;

                case CommandType.TermAck:
                    ProcessTermAck();
                    break;

                case CommandType.Reap:
                    ProcessReap((SocketBase)cmd.Arg);
                    break;

                case CommandType.Reaped:
                    ProcessReaped();
                    break;

                default:
                    throw new ArgumentException();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Send the given Command, on that commands Destination thread.
 /// </summary>
 /// <param name="cmd">the Command to send</param>
 private void SendCommand( Command cmd)
 {
     m_ctx.SendCommand(cmd.Destination.ThreadId, cmd);
 }
Esempio n. 8
0
 public bool TryRecv(out Command command)
 {
     return m_commandPipe.TryRead(out command);
 }
Esempio n. 9
0
        /// <summary>
        /// Receive and return a Command from the command-pipe.
        /// </summary>
        /// <param name="timeout">how long to wait for a command (in milliseconds) before returning</param>
        /// <param name="command"></param>
        public bool TryRecv(int timeout, out Command command)
        {
            // Try to get the command straight away.
            if (m_active)
            {
                if (m_commandPipe.TryRead(out command))
                    return true;

                // If there are no more commands available, switch into passive state.
                m_active = false;
                m_signaler.Recv();
            }

            // Wait for signal from the command sender.
            if (!m_signaler.WaitEvent(timeout))
            {
                command = default(Command);
                return false;
            }

            // We've got the signal. Now we can switch into active state.
            m_active = true;

            // Get a command.
            var ok = m_commandPipe.TryRead(out command);
            Debug.Assert(ok);
            return ok;
        }
Esempio n. 10
0
        /// <summary>
        /// Send the given Command out accross the command-pipe.
        /// </summary>
        /// <param name="cmd">the Command to send</param>
        public void Send(Command cmd)
        {
            bool ok;
            lock (m_sync)
            {
                m_commandPipe.Write(ref cmd, false);
                ok = m_commandPipe.Flush();
            }

            //if (LOG.isDebugEnabled())
            //    LOG.debug( "{} -> {} / {} {}", new Object[] { Thread.currentThread().getName(), cmd_, cmd_.arg , !ok});

            if (!ok)
            {
                m_signaler.Send();
            }
        }
Esempio n. 11
0
 private static void SendCommand(Command command)
 {
     SocketManager.SendCommand(command.Destination.SlotId, command);
 }
Esempio n. 12
0
 public void Send(Command command)
 {
     // using the completion port as a queue, might not yield good performance
     m_completionPort.Signal(command);
 }