Skip to content

Commit

Permalink
Add an optional prefix param to ScopedStepContainer to avoid possible…
Browse files Browse the repository at this point in the history
… name clashes

PiperOrigin-RevId: 232966938
  • Loading branch information
tensorflower-gardener committed Feb 8, 2019
1 parent 543b9f8 commit cb5f4b3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tensorflow/core/framework/resource_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ class ScopedStepContainer {
// step_id: the unique ID of this step. Doesn't have to be sequential, just
// has to be unique.
// cleanup: callback to delete a container of this name.
// prefix: optional string prefix to disambiguate step containers.
ScopedStepContainer(const int64 step_id,
std::function<void(const string&)> cleanup)
: name_(strings::StrCat("__per_step_", step_id)), cleanup_(cleanup) {}

ScopedStepContainer(const int64 step_id,
std::function<void(const string&)> cleanup,
const string& prefix)
: name_(strings::StrCat("__", prefix, "_per_step_", step_id)),
cleanup_(cleanup) {}

~ScopedStepContainer() { cleanup_(name_); }

const string& name() const { return name_; }
Expand Down

0 comments on commit cb5f4b3

Please sign in to comment.