blob: 7d9085ec44df8a42b8b8031a174bca7ff08ddabb [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
Konrad Grochowski9be4e682013-06-22 22:03:31 +020020#include <thrift/thrift-config.h>
21
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040022#include <thrift/Thrift.h>
Roger Meier4285ba22013-06-10 21:17:23 +020023#include <thrift/concurrency/Util.h>
Roger Meier2fa9c312011-09-05 19:15:53 +000024
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040025#if defined(HAVE_SYS_TIME_H)
David Reiss53f18f02008-07-11 00:45:29 +000026#include <sys/time.h>
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040027#endif
David Reiss53f18f02008-07-11 00:45:29 +000028
T Jake Lucianib5e62212009-01-31 22:36:20 +000029namespace apache { namespace thrift { namespace concurrency {
David Reiss53f18f02008-07-11 00:45:29 +000030
Roger Meier3b771a12010-11-17 22:11:26 +000031int64_t Util::currentTimeTicks(int64_t ticksPerSec) {
David Reiss53f18f02008-07-11 00:45:29 +000032 int64_t result;
David Reiss53f18f02008-07-11 00:45:29 +000033 struct timeval now;
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040034 int ret = THRIFT_GETTIMEOFDAY(&now, NULL);
David Reiss53f18f02008-07-11 00:45:29 +000035 assert(ret == 0);
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040036 THRIFT_UNUSED_VARIABLE(ret); //squelching "unused variable" warning
David Reiss7a2065d2010-03-09 05:20:04 +000037 toTicks(result, now, ticksPerSec);
David Reiss53f18f02008-07-11 00:45:29 +000038 return result;
39}
40
T Jake Lucianib5e62212009-01-31 22:36:20 +000041}}} // apache::thrift::concurrency