コード例 #1
0
ファイル: Req.cs プロジェクト: 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;
 }
コード例 #2
0
ファイル: Pull.cs プロジェクト: knocte/netmq
        public Pull(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Pull;

            m_fq = new FQ();
        }
コード例 #3
0
ファイル: Push.cs プロジェクト: knocte/netmq
        public Push(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Push;

            lb = new LB();
        }
コード例 #4
0
ファイル: Router.cs プロジェクト: knocte/netmq
        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;
        }
コード例 #5
0
ファイル: Rep.cs プロジェクト: 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;
        }
コード例 #6
0
ファイル: Sub.cs プロジェクト: 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;
        }
コード例 #7
0
ファイル: IOThread.cs プロジェクト: knocte/netmq
        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);
        }
コード例 #8
0
ファイル: XPub.cs プロジェクト: 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>();
        }
コード例 #9
0
ファイル: XSub.cs プロジェクト: 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();
        }
コード例 #10
0
ファイル: Own.cs プロジェクト: 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>();
        }
コード例 #11
0
ファイル: Reaper.cs プロジェクト: knocte/netmq
        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);
        }
コード例 #12
0
ファイル: Dealer.cs プロジェクト: knocte/netmq
        //  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;
        }
コード例 #13
0
ファイル: SocketBase.cs プロジェクト: knocte/netmq
        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);
        }
コード例 #14
0
ファイル: Pair.cs プロジェクト: knocte/netmq
 public Pair(Ctx parent, int tid, int sid)
     : base(parent, tid, sid)
 {
     m_options.SocketType = ZmqSocketType.Pair;
 }
コード例 #15
0
ファイル: ZMQ.cs プロジェクト: knocte/netmq
 public static int CtxGet(Ctx ctx, ContextOption option)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw new InvalidOperationException();
     }
     return ctx.Get(option);
 }
コード例 #16
0
ファイル: ZMQ.cs プロジェクト: knocte/netmq
        private static void CtxDestroy(Ctx ctx)
        {
            if (ctx == null || !ctx.CheckTag())
            {
                throw new InvalidOperationException();
            }

            ctx.Terminate();
        }
コード例 #17
0
ファイル: ZMQ.cs プロジェクト: knocte/netmq
 public static void Term(Ctx ctx)
 {
     CtxDestroy(ctx);
 }
コード例 #18
0
ファイル: ZMQ.cs プロジェクト: 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;
 }
コード例 #19
0
ファイル: ZMQ.cs プロジェクト: knocte/netmq
 public static void CtxSet(Ctx ctx, ContextOption option, int optval)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw new InvalidOperationException();
     }
     ctx.Set(option, optval);
 }
コード例 #20
0
ファイル: ZMQ.cs プロジェクト: knocte/netmq
 //  New context API
 public static Ctx CtxNew()
 {
     //  Create 0MQ context.
     Ctx ctx = new Ctx();
     return ctx;
 }
コード例 #21
0
ファイル: Context.cs プロジェクト: knocte/netmq
 private Context(Ctx ctx)
 {
     m_ctx = ctx;
 }
コード例 #22
0
ファイル: SocketBase.cs プロジェクト: knocte/netmq
        //  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;
        }