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


C# Ref.CurrentValPoint方法代码示例

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


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

示例1: DoEnsure

        /// <summary>
        /// Touch a ref.  (Lock it.)
        /// </summary>
        /// <param name="r">The ref to touch.</param>
        internal void DoEnsure(Ref r)
        {
            if (!_info.IsRunning)
                throw _retryex;
            if (_ensures.Contains(r))
                return;

            Lock(r);

            // someone completed a write after our shapshot
            if (r.CurrentValPoint() > _readPoint)
            {
                r.ExitReadLock();
                throw _retryex;
            }

            Info refinfo = r.TInfo;

            // writer exists
            if (refinfo != null && refinfo.IsRunning)
            {
                r.ExitReadLock();
                if (refinfo != _info)  // not us, ensure is doomed
                    BlockAndBail(refinfo);
            }
            else
                _ensures.Add(r);
        }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:32,代码来源:LockingTransaction.cs

示例2: Lock

        /// <summary>
        /// Lock a ref.
        /// </summary>
        /// <param name="r">The ref to lock.</param>
        /// <returns>The most recent value of the ref.</returns>
        object Lock(Ref r)
        {
            // can't upgrade read lock, so release it.
            ReleaseIfEnsured(r);

            bool unlocked = true;
            try
            {
                TryWriteLock(r);
                unlocked = false;

                if (r.CurrentValPoint() > _readPoint)
                    throw _retryex;

                Info refinfo = r.TInfo;

                // write lock conflict
                if (refinfo != null && refinfo != _info && refinfo.IsRunning)
                {
                    if (!Barge(refinfo))
                    {
                        r.ExitWriteLock();
                        unlocked = true;
                        return BlockAndBail(refinfo);
                    }
                }

                r.TInfo = _info;
                return r.TryGetVal();
            }
            finally
            {
                if (!unlocked)
                {
                    r.ExitWriteLock();
                }
            }
        }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:43,代码来源:LockingTransaction.cs

示例3: Lock

        /// <summary>
        /// Lock a ref.
        /// </summary>
        /// <param name="r">The ref to lock.</param>
        /// <returns>The current value of the ref.</returns>
        object Lock(Ref r)
        {
            bool unlocked = false;
            try
            {
                r.EnterWriteLock();
                if (r.CurrentValPoint() > _readPoint)
                    throw _retryex;

                Info refinfo = r.TInfo;

                // write lock conflict
                if (refinfo != null && refinfo != _info && refinfo.IsRunning)
                {
                    if (!barge(refinfo))
                    {
                        r.ExitWriteLock();
                        unlocked = true;
                        // stop prior to blocking
                        stop(RETRY);
                        lock (refinfo)
                        {
                            if (refinfo.IsRunning)
                            {
                                try
                                {
                                    Monitor.Wait(refinfo, LOCK_WAIT_MSECS);
                                }
                                catch (ThreadInterruptedException)
                                {
                                }
                            }
                        }
                        throw _retryex;
                    }
                }

                r.TInfo = _info;
                return r.TryGetVal();
            }
            finally
            {
                if (!unlocked)
                {
                    r.ExitWriteLock();
                }
            }
        }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:53,代码来源:LockingTransaction.cs


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