Esempio n. 1
0
File: Req.cs Progetto: knocte/netmq
 public Req(Ctx parent, int tid, int sid)
     : base(parent, tid, sid)
 {
     m_receivingReply = false;
     m_messageBegins = true;
     m_options.SocketType = ZmqSocketType.Req;
 }
Esempio n. 2
0
File: Pull.cs Progetto: knocte/netmq
        public Pull(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Pull;

            m_fq = new FQ();
        }
Esempio n. 3
0
File: Push.cs Progetto: knocte/netmq
        public Push(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Push;

            lb = new LB();
        }
Esempio n. 4
0
        public Router(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_prefetched = false;
            m_identitySent = false;
            m_moreIn = false;
            m_currentOut = null;
            m_moreOut = false;
            m_nextPeerId = Utils.GenerateRandom ();
            m_mandatory = false;

            m_options.SocketType = ZmqSocketType.Router;

            m_fq = new FQ();
            m_prefetchedId = new Msg();
            m_prefetchedMsg = new Msg();

            m_anonymousPipes = new HashSet<Pipe>();
            m_outpipes = new Dictionary<Blob, Outpipe>();

            //  TODO: Uncomment the following line when ROUTER will become true ROUTER
            //  rather than generic router socket.
            //  If peer disconnect there's noone to send reply to anyway. We can drop
            //  all the outstanding requests from that peer.
            //  options.delay_on_disconnect = false;

            m_options.RecvIdentity = true;
        }
Esempio n. 5
0
File: Rep.cs Progetto: knocte/netmq
        public Rep(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_sendingReply = false;
            m_requestBegins = true;

            m_options.SocketType = ZmqSocketType.Rep;
        }
Esempio n. 6
0
File: Sub.cs Progetto: knocte/netmq
        public Sub(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Sub;

            //  Switch filtering messages on (as opposed to XSUB which where the
            //  filtering is off).
            m_options.Filter = true;
        }
Esempio n. 7
0
        public IOThread(Ctx ctx, int tid)
            : base(ctx, tid)
        {
            m_name = "iothread-" + tid;
            m_poller = new Poller(m_name);

            m_mailbox = new Mailbox(m_name);
            m_mailboxHandle = m_mailbox.FD;
            m_poller.AddFD (m_mailboxHandle, this);
            m_poller.SetPollin (m_mailboxHandle);
        }
Esempio n. 8
0
File: XPub.cs Progetto: knocte/netmq
        public XPub(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Xpub;
            m_verbose = false;
            m_more = false;

            m_subscriptions = new Mtrie();
            m_dist = new Dist();
            m_pending = new Deque<Blob>();
        }
Esempio n. 9
0
File: XSub.cs Progetto: knocte/netmq
        public XSub(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Xsub;
            m_hasMessage = false;
            m_more = false;

            m_options.Linger = 0;
            m_fq = new FQ();
            m_dist = new Dist();
            m_subscriptions = new Trie();
        }
Esempio n. 10
0
File: Own.cs Progetto: knocte/netmq
        //  Note that the owner is unspecified in the constructor.
        //  It'll be supplied later on when the object is plugged in.
        //  The object is not living within an I/O thread. It has it's own
        //  thread outside of 0MQ infrastructure.
        public Own(Ctx parent, int tid)
            : base(parent, tid)
        {
            m_terminating = false;
            m_sentSeqnum = new AtomicLong(0);
            m_processedSeqnum = 0;
            m_owner = null;
            m_termAcks = 0;

            m_options = new Options();
            owned = new HashSet<Own>();
        }
Esempio n. 11
0
        public Reaper(Ctx ctx, int tid)
            : base(ctx, tid)
        {
            m_sockets = 0;
            m_terminating = false;
            m_name = "reaper-" + tid;
            m_poller = new Poller(m_name);

            mailbox = new Mailbox(m_name);

            m_mailboxHandle = mailbox.FD;
            m_poller.AddFD (m_mailboxHandle, this);
            m_poller.SetPollin (m_mailboxHandle);
        }
Esempio n. 12
0
        //  Holds the prefetched message.
        public Dealer(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_prefetched = false;
            m_options.SocketType = ZmqSocketType.Dealer;

            m_fq = new FQ();
            m_lb = new LB();
            //  TODO: Uncomment the following line when DEALER will become true DEALER
            //  rather than generic dealer socket.
            //  If the socket is closing we can drop all the outbound requests. There'll
            //  be noone to receive the replies anyway.
            //  options.delay_on_close = false;

            m_options.RecvIdentity = true;
        }
Esempio n. 13
0
        protected SocketBase(Ctx parent, int tid, int sid)
            : base(parent, tid)
        {
            m_tag = 0xbaddecaf;
            m_ctxTerminated = false;
            m_destroyed = false;
            m_lastTsc = 0;
            m_ticks = 0;
            m_rcvMore = false;
            m_monitorSocket = null;
            m_monitorEvents = 0;

            m_options.SocketId = sid;

            m_endpoints = new Dictionary<string, Own>();
            m_pipes = new List<Pipe>();

            m_mailbox = new Mailbox("socket-" + sid);
        }
Esempio n. 14
0
File: Pair.cs Progetto: knocte/netmq
 public Pair(Ctx parent, int tid, int sid)
     : base(parent, tid, sid)
 {
     m_options.SocketType = ZmqSocketType.Pair;
 }
Esempio n. 15
0
File: ZMQ.cs Progetto: knocte/netmq
 public static int CtxGet(Ctx ctx, ContextOption option)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw new InvalidOperationException();
     }
     return ctx.Get(option);
 }
Esempio n. 16
0
File: ZMQ.cs Progetto: knocte/netmq
        private static void CtxDestroy(Ctx ctx)
        {
            if (ctx == null || !ctx.CheckTag())
            {
                throw new InvalidOperationException();
            }

            ctx.Terminate();
        }
Esempio n. 17
0
File: ZMQ.cs Progetto: knocte/netmq
 public static void Term(Ctx ctx)
 {
     CtxDestroy(ctx);
 }
Esempio n. 18
0
File: ZMQ.cs Progetto: knocte/netmq
 // Sockets
 public static SocketBase Socket(Ctx ctx, ZmqSocketType type)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw new InvalidOperationException();
     }
     SocketBase s = ctx.CreateSocket(type);
     return s;
 }
Esempio n. 19
0
File: ZMQ.cs Progetto: knocte/netmq
 public static void CtxSet(Ctx ctx, ContextOption option, int optval)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw new InvalidOperationException();
     }
     ctx.Set(option, optval);
 }
Esempio n. 20
0
File: ZMQ.cs Progetto: knocte/netmq
 //  New context API
 public static Ctx CtxNew()
 {
     //  Create 0MQ context.
     Ctx ctx = new Ctx();
     return ctx;
 }
Esempio n. 21
0
 private Context(Ctx ctx)
 {
     m_ctx = ctx;
 }
Esempio n. 22
0
        //  Create a socket of a specified type.
        public static SocketBase Create(ZmqSocketType type, Ctx parent,
            int tid, int sid)
        {
            SocketBase s;
            switch (type)
            {

                case ZmqSocketType.Pair:
                    s = new Pair(parent, tid, sid);
                    break;
                case ZmqSocketType.Pub:
                    s = new Pub(parent, tid, sid);
                    break;
                case ZmqSocketType.Sub:
                    s = new Sub(parent, tid, sid);
                    break;
                case ZmqSocketType.Req:
                    s = new Req(parent, tid, sid);
                    break;
                case ZmqSocketType.Rep:
                    s = new Rep(parent, tid, sid);
                    break;
                case ZmqSocketType.Dealer:
                    s = new Dealer(parent, tid, sid);
                    break;
                case ZmqSocketType.Router:
                    s = new Router(parent, tid, sid);
                    break;
                case ZmqSocketType.Pull:
                    s = new Pull(parent, tid, sid);
                    break;
                case ZmqSocketType.Push:
                    s = new Push(parent, tid, sid);
                    break;

                case ZmqSocketType.Xpub:
                    s = new XPub(parent, tid, sid);
                    break;

                case ZmqSocketType.Xsub:
                    s = new XSub(parent, tid, sid);
                    break;

                default:
                    throw new ArgumentException("type=" + type);
            }
            return s;
        }