walltime.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The urg_stamped Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SCIP2_WALLTIME_H
18 #define SCIP2_WALLTIME_H
19 
20 #include <string>
21 
22 namespace scip2
23 {
24 template <int DEVICE_TIMESTAMP_BITS>
25 class Walltime
26 {
27 protected:
31 
32 public:
33  uint64_t update(const uint32_t &time_device)
34  {
35  if (!initialized_)
36  {
37  time_device_prev_ = time_device;
38  initialized_ = true;
39  }
40 
41  if (time_device < (1 << DEVICE_TIMESTAMP_BITS) / 2 &&
42  (1 << DEVICE_TIMESTAMP_BITS) / 2 < time_device_prev_)
43  walltime_device_base_ += 1 << DEVICE_TIMESTAMP_BITS;
44  time_device_prev_ = time_device;
45 
46  return walltime_device_base_ + time_device;
47  }
49  : initialized_(false)
50  , time_device_prev_(0)
51  , walltime_device_base_(0)
52  {
53  }
54 };
55 } // namespace scip2
56 
57 #endif // SCIP2_WALLTIME_H
uint64_t update(const uint32_t &time_device)
Definition: walltime.h:33
uint64_t walltime_device_base_
Definition: walltime.h:30
uint32_t time_device_prev_
Definition: walltime.h:29
bool initialized_
Definition: walltime.h:28


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Thu Jun 6 2019 19:55:59