MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
Timing.cpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2
// SPDX-License-Identifier: Apache-2.0
3
4
#include "
mxl-internal/Timing.hpp
"
5
#include <
mxl/platform.h
>
6
#include "
mxl-internal/detail/ClockHelpers.hpp
"
7
8
namespace
mxl::lib
9
{
10
MXL_EXPORT
11
Timepoint
currentTime
(
Clock
clock)
noexcept
12
{
13
auto
result =
Timepoint
{};
14
15
std::timespec ts;
16
if
(::clock_gettime(
detail::clockToId
(clock), &ts) == 0)
17
{
18
result =
asTimepoint
(ts) +
detail::getClockOffset
(clock);
19
}
20
return
result;
21
}
22
23
Timepoint
currentTimeUTC
() noexcept
24
{
25
auto
result =
Timepoint
{};
26
27
std::timespec ts;
28
if
(::timespec_get(&ts, TIME_UTC) != 0)
29
{
30
result =
asTimepoint
(ts);
31
}
32
return
result;
33
}
34
}
ClockHelpers.hpp
Timing.hpp
mxl::lib::detail::clockToId
constexpr clockid_t clockToId(Clock clock) noexcept
Definition
ClockHelpers.hpp:11
mxl::lib::detail::getClockOffset
constexpr Duration getClockOffset(Clock clock) noexcept
Definition
ClockHelpers.hpp:33
mxl::lib
Definition
fabrics.cpp:33
mxl::lib::asTimepoint
constexpr Timepoint asTimepoint(std::timespec const &timepoint) noexcept
Definition
Timing.hpp:236
mxl::lib::currentTimeUTC
Timepoint currentTimeUTC() noexcept
Definition
Timing.cpp:23
mxl::lib::Clock
Clock
Definition
Timing.hpp:15
platform.h
MXL_EXPORT
#define MXL_EXPORT
Definition
platform.h:9
mxl::lib::Timepoint
Definition
Timing.hpp:175
currentTime
auto const currentTime
Definition
test_time.cpp:58
lib
internal
src
Timing.cpp
Generated by
1.15.0