当前位置: 首页>>代码示例>>C#>>正文


C# Channel.get方法代码示例

本文整理汇总了C#中Channel.get方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.get方法的具体用法?C# Channel.get怎么用?C# Channel.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Channel的用法示例。


在下文中一共展示了Channel.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: deliverMsgs

        // deliverMsgs waits on the delivery channel shared with readLoop and processMsg.
        // It is used to deliver messages to asynchronous subscribers.
        internal void deliverMsgs(Channel<Msg> ch)
        {
            Msg m;

            while (true)
            {
                lock (mu)
                {
                    if (isClosed())
                        return;
                }
 
                m = ch.get(-1);
                if (m == null)
                {
                    // the channel has been closed, exit silently.
                    return;
                }

                // Note, this seems odd message having the sub process itself, 
                // but this is good for performance.
                if (!m.sub.processMsg(m))
                {
                    lock (mu)
                    {
                        removeSub(m.sub);
                    }
                }
            }
        }
开发者ID:bendan365,项目名称:csnats-wip,代码行数:32,代码来源:Conn.cs

示例2: Flush

        public void Flush(int timeout)
        {
            if (timeout <= 0)
            {
                throw new ArgumentOutOfRangeException(
                    "Timeout must be greater than 0",
                    "timeout");
            }

            Channel<bool> ch = new Channel<bool>(1);
            lock (mu)
            {
                if (isClosed())
                    throw new NATSConnectionClosedException();

                sendPing(ch);
            }

            try
            {
                bool rv = ch.get(timeout);
                if (!rv)
                {
                    lastEx = new NATSConnectionClosedException();
                }
            }
            catch (NATSTimeoutException te)
            {
                lastEx = te;
            }
            catch (Exception e)
            {
                lastEx = new NATSException("Flush channel error.", e);
            }

            if (lastEx != null)
            {
                removeFlushEntry(ch);
                throw lastEx;
            }
        }
开发者ID:bendan365,项目名称:csnats-wip,代码行数:41,代码来源:Conn.cs

示例3: Flush

        public void Flush(int timeout)
        {
            if (timeout <= 0)
            {
                throw new ArgumentOutOfRangeException(
                    "Timeout must be greater than 0",
                    "timeout");
            }

            Channel<bool> ch = new Channel<bool>(1);

            try
            {
                lock (mu)
                {
                    if (isClosed())
                        throw new NATSConnectionClosedException();

                    sendPing(ch);
                }

                bool rv = ch.get(timeout);
                if (!rv)
                {
                    throw new NATSConnectionClosedException();
                }
            }
            catch (Exception e)
            {
                removeFlushEntry(ch);

                // Note, don't call saveFlushException in a finally clause
                // because we don't know if the caller will handle the rethrown 
                // exception.
                if (e is NATSTimeoutException || e is NATSConnectionClosedException)
                {
                    saveFlushException(ch, e);
                    throw;
                }
                else
                {
                    // wrap other system exceptions
                    var ex = new NATSException("Flush error.", e);
                    saveFlushException(ch, ex);
                    throw ex;
                }
            }
        }
开发者ID:nats-io,项目名称:csnats,代码行数:48,代码来源:Conn.cs


注:本文中的Channel.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。