blob: 868f52fdfda36b9f16437b5a8e3a12e8a67b2197 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
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 Reiss53f18f02008-07-11 00:45:29 +000019
David Reiss53f18f02008-07-11 00:45:29 +000020#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040023#include <thrift/Thrift.h>
Roger Meier4285ba22013-06-10 21:17:23 +020024#include <thrift/concurrency/Util.h>
Roger Meier2fa9c312011-09-05 19:15:53 +000025
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040026#if defined(HAVE_SYS_TIME_H)
David Reiss53f18f02008-07-11 00:45:29 +000027#include <sys/time.h>
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040028#endif
David Reiss53f18f02008-07-11 00:45:29 +000029
T Jake Lucianib5e62212009-01-31 22:36:20 +000030namespace apache { namespace thrift { namespace concurrency {
David Reiss53f18f02008-07-11 00:45:29 +000031
Roger Meier3b771a12010-11-17 22:11:26 +000032int64_t Util::currentTimeTicks(int64_t ticksPerSec) {
David Reiss53f18f02008-07-11 00:45:29 +000033 int64_t result;
David Reiss53f18f02008-07-11 00:45:29 +000034 struct timeval now;
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040035 int ret = THRIFT_GETTIMEOFDAY(&now, NULL);
David Reiss53f18f02008-07-11 00:45:29 +000036 assert(ret == 0);
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040037 THRIFT_UNUSED_VARIABLE(ret); //squelching "unused variable" warning
David Reiss7a2065d2010-03-09 05:20:04 +000038 toTicks(result, now, ticksPerSec);
David Reiss53f18f02008-07-11 00:45:29 +000039 return result;
40}
41
T Jake Lucianib5e62212009-01-31 22:36:20 +000042}}} // apache::thrift::concurrency