anchor.diff:      | TryGetResult of IReplyChannel<Result<'T> option>
   
   /// Defines a reference to a distributed result cell instance.
  -type ResultCell<'T> private (id : string, source : ActorRef<ResultCellMsg<'T>>) as self =
  +type TaskCompletionSource<'T> private (id : string, source : ActorRef<ResultCellMsg<'T>>) as self =
       [<NonSerialized>]
       let mutable localCell : CacheAtom<Result<'T> option> option = None
       let getLocalCell() =
  
positive.code:         return resource :?> 'T
      }
  
      member __.RequestLatch(count) = __.RequestResource(fun () -> Latch.Init(count))
      member __.RequestResultAggregator<'T>(count : int) = __.RequestResource(fun () -> ResultAggregator<'T>.Init(count))
      member __.RequestCancellationTokenSource() = __.RequestResource(fun () -> DistributedCancellationTokenSource.Init())
      member __.RequestResultCell<'T>() = __.RequestResource(fun () -> ResultCell<'T>.Init())
      member __.RequestChannel<'T>(id) = __.RequestResource(fun () -> Channel<'T>.Init(id))
      member __.RequestDictionary<'T>() = __.RequestResource(fun () -> CloudDictionary<'T>.Init())
      member __.RequestAtom<'T>(id, init) = __.RequestResource(fun () -> Atom<'T>.Init(id, init))
  
negative.code: //
  
  type private ResultAggregatorMsg<'T> =
      | SetResult of index:int * value:'T * overwrite:bool * completed:IReplyChannel<bool>
      | GetCompleted of IReplyChannel<int>
      | IsCompleted of IReplyChannel<bool>
      | ToArray of IReplyChannel<'T []>
  
  /// A distributed resource that aggregates an array of results.
  type ResultAggregator<'T> private (capacity : int, source : ActorRef<ResultAggregatorMsg<'T>>) =
      interface IResultAggregator<'T> with
          member __.Capacity = capacity
          member __.CurrentSize = source <!- GetCompleted
          member __.IsCompleted = source <!- IsCompleted
          member __.SetResult(index : int, value : 'T, overwrite : bool) = source <!- fun ch -> SetResult(index, value, overwrite, ch)
          member __.ToArray () = source <!- ToArray
          member __.Dispose () = async.Zero()
  
      /// Initializes a result aggregator of given size at the current process.
      static member Init(size : int) =
          let behaviour (results : Map<int, 'T>) msg = async {
              match msg with
              | SetResult(i, value, _, rc) when i < 0 || i >= size ->
                  let e = new IndexOutOfRangeException()
                  do! rc.ReplyWithException e
                  return results
  
              | SetResult(i, value, false, rc) when results.ContainsKey i ->
                  let e = new InvalidOperationException(sprintf "result at position '%d' has already been set." i)
                  do! rc.ReplyWithException e
                  return results
  
              | SetResult(i, value, _, rc) ->
                  let results = results.Add(i, value)
                  let isCompleted = results.Count = size
                  do! rc.Reply isCompleted
                  return results
  
              | GetCompleted rc ->
                  do! rc.Reply results.Count
                  return results
  
              | IsCompleted rc ->
                  do! rc.Reply ((results.Count = size))
                  return results
  