1 // Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // ============================================================================= 15 #ifndef TENSORFLOW_CONTRIB_BOOSTED_TREES_RESOURCES_STAMPED_RESOURCE_H_ 16 #define TENSORFLOW_CONTRIB_BOOSTED_TREES_RESOURCES_STAMPED_RESOURCE_H_ 17 18 #include "tensorflow/core/framework/resource_mgr.h" 19 #include "tensorflow/core/platform/mutex.h" 20 21 namespace tensorflow { 22 namespace boosted_trees { 23 24 // A StampedResource is a resource that has a stamp token associated with it. 25 // Before reading from or applying updates to the resource, the stamp should 26 // be checked to verify that the update is not stale. 27 class StampedResource : public ResourceBase { 28 public: StampedResource()29 StampedResource() : stamp_(-1) {} 30 is_stamp_valid(int64 stamp)31 bool is_stamp_valid(int64 stamp) const { return stamp_ == stamp; } 32 stamp()33 int64 stamp() const { return stamp_; } set_stamp(int64 stamp)34 void set_stamp(int64 stamp) { stamp_ = stamp; } 35 36 private: 37 int64 stamp_; 38 }; 39 40 } // namespace boosted_trees 41 } // namespace tensorflow 42 #endif // TENSORFLOW_CONTRIB_BOOSTED_TREES_RESOURCES_STAMPED_RESOURCE_H_ 43