Reuse tensorflow::MakeUnique

Change-Id: If62f8399c8a885f287bba62ecd244ce98561ae64
This commit is contained in:
jiakai 2019-06-14 21:02:15 +08:00
parent f45c45d906
commit ace5884d71

View File

@ -15,16 +15,9 @@ limitations under the License.
#include "tensorflow/core/distributed_runtime/partial_run_mgr.h"
namespace tensorflow {
#include "tensorflow/core/util/ptr_util.h"
namespace {
// TODO(suharshs): Move this to a common location to allow other part of the
// repo to use it.
template <typename T, typename... Args>
std::unique_ptr<T> MakeUnique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
} // namespace
namespace tensorflow {
bool PartialRunMgr::FindOrCreate(int step_id,
CancellationManager** cancellation_manager) {
@ -35,8 +28,8 @@ bool PartialRunMgr::FindOrCreate(int step_id,
return false;
}
std::unique_ptr<PartialRunState> partial_run = MakeUnique<PartialRunState>();
partial_run->cancellation_manager = MakeUnique<CancellationManager>();
std::unique_ptr<PartialRunState> partial_run = tensorflow::MakeUnique<PartialRunState>();
partial_run->cancellation_manager = tensorflow::MakeUnique<CancellationManager>();
*cancellation_manager = partial_run->cancellation_manager.get();
step_id_to_partial_run_[step_id] = std::move(partial_run);
return true;