CCF
Loading...
Searching...
No Matches
src
host
time_updater.h
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the Apache 2.0 License.
3
#pragma once
4
5
#include "
timer.h
"
6
7
#include <atomic>
8
#include <chrono>
9
10
namespace
asynchost
11
{
12
class
TimeUpdaterImpl
13
{
14
std::atomic<long long> time_now_us;
15
16
public
:
17
TimeUpdaterImpl
()
18
{
19
on_timer
();
20
}
21
22
std::atomic<long long>*
get_value
()
23
{
24
return
&time_now_us;
25
}
26
27
void
on_timer
()
28
{
29
using
TClock = std::chrono::system_clock;
30
time_now_us = std::chrono::duration_cast<std::chrono::microseconds>(
31
TClock::now().time_since_epoch())
32
.count();
33
}
34
};
35
36
using
TimeUpdater
=
proxy_ptr<Timer<TimeUpdaterImpl>
>;
37
}
asynchost::TimeUpdaterImpl
Definition
time_updater.h:13
asynchost::TimeUpdaterImpl::TimeUpdaterImpl
TimeUpdaterImpl()
Definition
time_updater.h:17
asynchost::TimeUpdaterImpl::on_timer
void on_timer()
Definition
time_updater.h:27
asynchost::TimeUpdaterImpl::get_value
std::atomic< long long > * get_value()
Definition
time_updater.h:22
asynchost::proxy_ptr
Definition
proxy.h:50
asynchost
Definition
after_io.h:8
timer.h
Generated by
1.9.8