David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 19 | |
Konrad Grochowski | 9be4e68 | 2013-06-22 22:03:31 +0200 | [diff] [blame] | 20 | #include <thrift/thrift-config.h> |
| 21 | |
Carl Yeksigian | 7cb7fc8 | 2013-06-07 07:33:01 -0400 | [diff] [blame] | 22 | #include <thrift/Thrift.h> |
Roger Meier | 4285ba2 | 2013-06-10 21:17:23 +0200 | [diff] [blame] | 23 | #include <thrift/concurrency/Util.h> |
Roger Meier | 2fa9c31 | 2011-09-05 19:15:53 +0000 | [diff] [blame] | 24 | |
Carl Yeksigian | 7cb7fc8 | 2013-06-07 07:33:01 -0400 | [diff] [blame] | 25 | #if defined(HAVE_SYS_TIME_H) |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 26 | #include <sys/time.h> |
Carl Yeksigian | 7cb7fc8 | 2013-06-07 07:33:01 -0400 | [diff] [blame] | 27 | #endif |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 28 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 29 | namespace apache { namespace thrift { namespace concurrency { |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 30 | |
Roger Meier | 3b771a1 | 2010-11-17 22:11:26 +0000 | [diff] [blame] | 31 | int64_t Util::currentTimeTicks(int64_t ticksPerSec) { |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 32 | int64_t result; |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 33 | struct timeval now; |
Carl Yeksigian | 7cb7fc8 | 2013-06-07 07:33:01 -0400 | [diff] [blame] | 34 | int ret = THRIFT_GETTIMEOFDAY(&now, NULL); |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 35 | assert(ret == 0); |
Carl Yeksigian | 7cb7fc8 | 2013-06-07 07:33:01 -0400 | [diff] [blame] | 36 | THRIFT_UNUSED_VARIABLE(ret); //squelching "unused variable" warning |
David Reiss | 7a2065d | 2010-03-09 05:20:04 +0000 | [diff] [blame] | 37 | toTicks(result, now, ticksPerSec); |
David Reiss | 53f18f0 | 2008-07-11 00:45:29 +0000 | [diff] [blame] | 38 | return result; |
| 39 | } |
| 40 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 41 | }}} // apache::thrift::concurrency |