Home | History | Annotate | Download | only in platform
      1 /* Copyright 2015 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_CORE_PLATFORM_ENV_TIME_H_
     16 #define TENSORFLOW_CORE_PLATFORM_ENV_TIME_H_
     17 
     18 #include <stdint.h>
     19 
     20 #include "tensorflow/core/platform/types.h"
     21 
     22 namespace tensorflow {
     23 
     24 /// \brief An interface used by the tensorflow implementation to
     25 /// access timer related operations.
     26 class EnvTime {
     27  public:
     28   EnvTime();
     29   virtual ~EnvTime() = default;
     30 
     31   /// \brief Returns a default impl suitable for the current operating
     32   /// system.
     33   ///
     34   /// The result of Default() belongs to this library and must never be deleted.
     35   static EnvTime* Default();
     36 
     37   /// \brief Returns the number of micro-seconds since the Unix epoch.
     38   virtual uint64 NowMicros() = 0;
     39 
     40   /// \brief Returns the number of seconds since the Unix epoch.
     41   virtual uint64 NowSeconds() { return NowMicros() / 1000000L; }
     42 };
     43 
     44 }  // namespace tensorflow
     45 
     46 #endif  // TENSORFLOW_CORE_PLATFORM_ENV_TIME_H_
     47