2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/system/common/time-service.h>
37 void GetNanoseconds( uint64_t& timeInNanoseconds )
39 // Get the time of a monotonic clock since its epoch.
40 auto epoch = std::chrono::steady_clock::now().time_since_epoch();
42 auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(epoch);
44 timeInNanoseconds = static_cast<uint64_t>(duration.count());
47 uint32_t GetMilliSeconds()
49 // Get the time of a monotonic clock since its epoch.
50 auto epoch = std::chrono::steady_clock::now().time_since_epoch();
52 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(epoch);
54 return static_cast<uint32_t>(duration.count());
58 void SleepUntil( uint64_t timeInNanoseconds )
60 using Clock = std::chrono::steady_clock;
61 using TimePoint = std::chrono::time_point<Clock>;
63 const Clock::duration duration = std::chrono::nanoseconds(timeInNanoseconds);
64 const TimePoint timePoint(duration);
66 std::this_thread::sleep_until(timePoint);
69 } // namespace TimeService
71 } // namespace Adaptor
73 } // namespace Internal