Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
70c068c9
R
rocksdb
项目概览
kvdb
/
rocksdb
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rocksdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
70c068c9
编写于
2月 02, 2016
作者:
S
Siying Dong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #960 from koldat/masterFixes2
Making use of GetSystemTimePreciseAsFileTime dynamic
上级
9c2cf947
a62c519b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
22 deletion
+45
-22
db/auto_roll_logger.cc
db/auto_roll_logger.cc
+10
-2
port/win/env_win.cc
port/win/env_win.cc
+35
-20
未找到文件。
db/auto_roll_logger.cc
浏览文件 @
70c068c9
...
...
@@ -32,8 +32,16 @@ Status AutoRollLogger::ResetLogger() {
}
void
AutoRollLogger
::
RollLogFile
()
{
std
::
string
old_fname
=
OldInfoLogFileName
(
dbname_
,
env_
->
NowMicros
(),
db_absolute_path_
,
db_log_dir_
);
// This function is called when log is rotating. Two rotations
// can happen quickly (NowMicro returns same value). To not overwrite
// previous log file we increment by one micro second and try again.
uint64_t
now
=
env_
->
NowMicros
();
std
::
string
old_fname
;
do
{
old_fname
=
OldInfoLogFileName
(
dbname_
,
now
,
db_absolute_path_
,
db_log_dir_
);
now
++
;
}
while
(
env_
->
FileExists
(
old_fname
).
ok
());
env_
->
RenameFile
(
log_fname_
,
old_fname
);
}
...
...
port/win/env_win.cc
浏览文件 @
70c068c9
...
...
@@ -1138,6 +1138,8 @@ void WinthreadCall(const char* label, std::error_code result) {
}
}
typedef
VOID
(
WINAPI
*
FnGetSystemTimePreciseAsFileTime
)(
LPFILETIME
);
class
WinEnv
:
public
Env
{
public:
WinEnv
();
...
...
@@ -1676,25 +1678,29 @@ class WinEnv : public Env {
}
virtual
uint64_t
NowMicros
()
override
{
// all std::chrono clocks on windows proved to return
// values that may repeat that is not good enough for some uses.
const
int64_t
c_UnixEpochStartTicks
=
116444736000000000
i64
;
const
int64_t
c_FtToMicroSec
=
10
;
// This interface needs to return system time and not
// just any microseconds because it is often used as an argument
// to TimedWait() on condition variable
FILETIME
ftSystemTime
;
GetSystemTimePreciseAsFileTime
(
&
ftSystemTime
);
LARGE_INTEGER
li
;
li
.
LowPart
=
ftSystemTime
.
dwLowDateTime
;
li
.
HighPart
=
ftSystemTime
.
dwHighDateTime
;
// Subtract unix epoch start
li
.
QuadPart
-=
c_UnixEpochStartTicks
;
// Convert to microsecs
li
.
QuadPart
/=
c_FtToMicroSec
;
return
li
.
QuadPart
;
if
(
GetSystemTimePreciseAsFileTime_
!=
NULL
)
{
// all std::chrono clocks on windows proved to return
// values that may repeat that is not good enough for some uses.
const
int64_t
c_UnixEpochStartTicks
=
116444736000000000
i64
;
const
int64_t
c_FtToMicroSec
=
10
;
// This interface needs to return system time and not
// just any microseconds because it is often used as an argument
// to TimedWait() on condition variable
FILETIME
ftSystemTime
;
GetSystemTimePreciseAsFileTime_
(
&
ftSystemTime
);
LARGE_INTEGER
li
;
li
.
LowPart
=
ftSystemTime
.
dwLowDateTime
;
li
.
HighPart
=
ftSystemTime
.
dwHighDateTime
;
// Subtract unix epoch start
li
.
QuadPart
-=
c_UnixEpochStartTicks
;
// Convert to microsecs
li
.
QuadPart
/=
c_FtToMicroSec
;
return
li
.
QuadPart
;
}
using
namespace
std
::
chrono
;
return
duration_cast
<
microseconds
>
(
system_clock
::
now
().
time_since_epoch
()).
count
();
}
virtual
uint64_t
NowNanos
()
override
{
...
...
@@ -2104,6 +2110,7 @@ class WinEnv : public Env {
std
::
vector
<
ThreadPool
>
thread_pools_
;
mutable
std
::
mutex
mu_
;
std
::
vector
<
std
::
thread
>
threads_to_join_
;
FnGetSystemTimePreciseAsFileTime
GetSystemTimePreciseAsFileTime_
;
};
WinEnv
::
WinEnv
()
...
...
@@ -2112,7 +2119,15 @@ WinEnv::WinEnv()
page_size_
(
4
*
1012
),
allocation_granularity_
(
page_size_
),
perf_counter_frequency_
(
0
),
thread_pools_
(
Priority
::
TOTAL
)
{
thread_pools_
(
Priority
::
TOTAL
),
GetSystemTimePreciseAsFileTime_
(
NULL
)
{
HMODULE
module
=
GetModuleHandle
(
"kernel32.dll"
);
if
(
module
!=
NULL
)
{
GetSystemTimePreciseAsFileTime_
=
(
FnGetSystemTimePreciseAsFileTime
)
GetProcAddress
(
module
,
"GetSystemTimePreciseAsFileTime"
);
}
SYSTEM_INFO
sinfo
;
GetSystemInfo
(
&
sinfo
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录