Ejemplo n.º 1
0
 /// <summary>
 /// Places the instance into the cache for re-use. This is invoked implicitly when a <see cref="ReusableTask"/> is awaited.
 /// </summary>
 /// <param name="result">The instance to place in the cache</param>
 internal static void Release(ResultHolder <EmptyStruct> result)
 {
     // This is neither cachable or resettable.
     result.Reset();
     lock (Cache)
         if (Cache.Count < MaximumCacheSize)
         {
             Cache.Push(result);
         }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Places the instance into the cache for re-use. This is invoked implicitly when a <see cref="ReusableTask{T}"/> is awaited.
 /// </summary>
 /// <param name="result">The instance to place in the cache</param>
 internal static void Release(ResultHolder <T> result)
 {
     // This is always resettable, but sometimes cacheable.
     result.Reset();
     if (result.Cacheable)
     {
         lock (Cache)
             if (Cache.Count < MaximumCacheSize)
             {
                 Cache.Push(result);
             }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <param name="resultHolder"></param>
 internal ReusableTaskAwaiter(int id, ResultHolder <EmptyStruct> resultHolder)
 {
     Id     = id;
     Result = resultHolder;
 }