aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2018-09-28 15:48:20 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-28 15:52:10 -0700
commitf5086804c758812ec9ed67233c58e18236246299 (patch)
tree7754539854c02c841669033565e75f12c05e0b4c /tensorflow/core/framework
parente4eeda33ca1d4a08ae2be7400f71b218fba25ccc (diff)
Add documentation of the ownership semantics to {Lookup,Create,LookupOrCreate}Resource().
PiperOrigin-RevId: 215008650
Diffstat (limited to 'tensorflow/core/framework')
-rw-r--r--tensorflow/core/framework/resource_mgr.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/tensorflow/core/framework/resource_mgr.h b/tensorflow/core/framework/resource_mgr.h
index abb6635984..4a531648d9 100644
--- a/tensorflow/core/framework/resource_mgr.h
+++ b/tensorflow/core/framework/resource_mgr.h
@@ -248,10 +248,16 @@ Status HandleFromInput(OpKernelContext* ctx, StringPiece input,
ResourceHandle* handle);
// Create a resource pointed by a given resource handle.
+//
+// If successful, the caller transfers the ownership of one ref on `resource` to
+// `ctx->resource_mgr()`.
template <typename T>
Status CreateResource(OpKernelContext* ctx, const ResourceHandle& p, T* value);
// Looks up a resource pointed by a given resource handle.
+//
+// If the lookup is successful, the caller takes the ownership of one ref on
+// `*value`, and must call its `Unref()` method when it has finished using it.
template <typename T>
Status LookupResource(OpKernelContext* ctx, const ResourceHandle& p, T** value);
@@ -262,6 +268,11 @@ Status LookupResources(
std::vector<std::unique_ptr<T, core::RefCountDeleter>>* values);
// Looks up or creates a resource.
+//
+// If successful, the caller takes the ownership of one ref on `*value`, and
+// must call its `Unref()` method when it has finished using it. If the
+// `creator` is invoked, its reference on the created resource is transferred
+// to `ctx->resource_mgr()`.
template <typename T>
Status LookupOrCreateResource(OpKernelContext* ctx, const ResourceHandle& p,
T** value, std::function<Status(T**)> creator);