message: Fixes potential race in ResourceHandleOp::Compute
  Fixes
diff: @@ -339,7 +339,7 @@ class ResourceHandleOp : public OpKernel {
  string container_;
  string name_;
  mutex mutex_;
  - Tensor resource_ GUARDED_BY(mutex_);
  + Tensor resource_;
  std::atomic<bool> initialized_{false};
  };
  @@ -516,6 +516,8 @@ template <typename T>
  void ResourceHandleOp<T>::Compute(OpKernelContext* ctx) {
  if (!initialized_.load()) {
  mutex_lock ml(mutex_);
  + // Checking again to see if another thread has initialized the resource.
  + if (!initialized_.load()) {
  AllocatorAttributes attr;
  attr.set_on_host(true);
  OP_REQUIRES_OK(ctx, ctx->allocate_temp(DT_RESOURCE, TensorShape({}),
  @@ -524,6 +526,7 @@ void ResourceHandleOp<T>::Compute(OpKernelContext* ctx) {
  MakeResourceHandle<T>(ctx, container_, name_);
  initialized_.store(true);
  }
  + }
  ctx->set_output(0, resource_);
  }
  