本文整理汇总了C#中Ref.ExitReadLock方法的典型用法代码示例。如果您正苦于以下问题:C# Ref.ExitReadLock方法的具体用法?C# Ref.ExitReadLock怎么用?C# Ref.ExitReadLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ref
的用法示例。
在下文中一共展示了Ref.ExitReadLock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReleaseIfEnsured
void ReleaseIfEnsured(Ref r)
{
if (_ensures.Contains(r))
{
_ensures.Remove(r);
r.ExitReadLock();
}
}
示例2: 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);
}
示例3: DoGet
/// <summary>
/// Get the value of a ref most recently set in this transaction (or prior to entering).
/// </summary>
/// <param name="r"></param>
/// <param name="tvals"></param>
/// <returns>The value.</returns>
internal object DoGet(Ref r)
{
if (!_info.IsRunning)
throw _retryex;
if (_vals.ContainsKey(r))
{
return _vals[r];
}
try
{
r.EnterReadLock();
if (r.TVals == null)
throw new InvalidOperationException(r.ToString() + " is not bound.");
Ref.TVal ver = r.TVals;
do
{
if (ver.Point <= _readPoint)
{
return ver.Val;
}
} while ((ver = ver.Prior) != r.TVals);
}
finally
{
r.ExitReadLock();
}
// no version of val precedes the read point
r.AddFault();
throw _retryex;
}
示例4: DoCommute
/// <summary>
/// Post a commute on a ref in this transaction.
/// </summary>
/// <param name="r">The ref.</param>
/// <param name="fn">The commuting function.</param>
/// <param name="args">Additional arguments to the function.</param>
/// <returns>The computed value.</returns>
internal object DoCommute(Ref r, IFn fn, ISeq args)
{
if (!_info.IsRunning)
throw _retryex;
if (!_vals.ContainsKey(r))
{
object val = null;
try
{
r.EnterReadLock();
val = r.TryGetVal();
}
finally
{
r.ExitReadLock();
}
_vals[r] = val;
}
List<CFn> fns;
if (! _commutes.TryGetValue(r, out fns))
_commutes[r] = fns = new List<CFn>();
fns.Add(new CFn(fn, args));
object ret = fn.applyTo(RT.cons(_vals[r], args));
_vals[r] = ret;
return ret;
}