File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 55#include < condition_variable>
66
77namespace rpp {
8- inline timespec to_timespec (const std::chrono::system_clock::time_point& tp);
8+
9+ template <class Clock , class Duration >
10+ inline timespec to_timespec (const std::chrono::time_point<Clock, Duration>& tp)
11+ {
12+ using namespace std ::chrono;
13+
14+ // Get duration since the system_clock epoch, in nanoseconds
15+ auto d = tp.time_since_epoch ();
16+ auto ns = duration_cast<nanoseconds>(d).count ();
17+
18+ timespec ts;
19+ ts.tv_sec = ns / 1'000'000'000 ;
20+ ts.tv_nsec = ns % 1'000'000'000 ;
21+ return ts;
22+ }
923
1024 class shm_mutex
1125 {
@@ -115,18 +129,4 @@ namespace rpp {
115129 native_handle_type native_handle () noexcept { return &handle; }
116130 };
117131
118- inline timespec to_timespec (const std::chrono::system_clock::time_point& tp)
119- {
120- using namespace std ::chrono;
121-
122- // Get duration since the system_clock epoch, in nanoseconds
123- auto d = tp.time_since_epoch ();
124- auto ns = duration_cast<nanoseconds>(d).count ();
125-
126- timespec ts;
127- ts.tv_sec = ns / 1'000'000'000 ;
128- ts.tv_nsec = ns % 1'000'000'000 ;
129- return ts;
130- }
131-
132132} // namespace rpp
You can’t perform that action at this time.
0 commit comments