Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
b54c3474
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,发现更多精彩内容 >>
提交
b54c3474
编写于
4月 22, 2016
作者:
P
PraveenSinghRao
提交者:
Siying Dong
4月 22, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use async file handle for better parallelism (#1049)
上级
c146c9be
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
4 deletion
+29
-4
port/win/env_win.cc
port/win/env_win.cc
+29
-4
未找到文件。
port/win/env_win.cc
浏览文件 @
b54c3474
...
...
@@ -124,6 +124,8 @@ SSIZE_T pwrite(HANDLE hFile, const char* src, size_t numBytes,
}
// See comments for pwrite above
// PLEASE NOTE: hFile is expected to be an async handle
// (i.e. opened with FILE_FLAG_OVERLAPPED)
SSIZE_T
pread
(
HANDLE
hFile
,
char
*
src
,
size_t
numBytes
,
uint64_t
offset
)
{
assert
(
numBytes
<=
std
::
numeric_limits
<
DWORD
>::
max
());
OVERLAPPED
overlapped
=
{
0
};
...
...
@@ -132,18 +134,33 @@ SSIZE_T pread(HANDLE hFile, char* src, size_t numBytes, uint64_t offset) {
overlapped
.
Offset
=
offsetUnion
.
LowPart
;
overlapped
.
OffsetHigh
=
offsetUnion
.
HighPart
;
overlapped
.
hEvent
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
if
(
NULL
==
overlapped
.
hEvent
)
{
return
-
1
;
}
SSIZE_T
result
=
0
;
unsigned
long
bytesRead
=
0
;
DWORD
lastError
=
ERROR_SUCCESS
;
if
(
FALSE
==
ReadFile
(
hFile
,
src
,
static_cast
<
DWORD
>
(
numBytes
),
&
bytesRead
,
&
overlapped
))
{
re
turn
-
1
;
if
(
(
FALSE
==
ReadFile
(
hFile
,
src
,
static_cast
<
DWORD
>
(
numBytes
),
&
bytesRead
,
&
overlapped
))
&&
((
lastError
=
GetLastError
())
!=
ERROR_IO_PENDING
))
{
re
sult
=
(
lastError
==
ERROR_HANDLE_EOF
)
?
0
:
-
1
;
}
else
{
result
=
bytesRead
;
if
(
lastError
==
ERROR_IO_PENDING
)
{
//otherwise bytesRead already has the result
if
(
FALSE
==
GetOverlappedResult
(
hFile
,
&
overlapped
,
&
bytesRead
,
TRUE
))
{
result
=
(
GetLastError
()
==
ERROR_HANDLE_EOF
)
?
0
:
-
1
;
}
else
{
result
=
bytesRead
;
}
}
}
CloseHandle
(
overlapped
.
hEvent
);
return
result
;
}
...
...
@@ -684,6 +701,8 @@ class WinSequentialFile : public SequentialFile {
// pread() based random-access
class
WinRandomAccessFile
:
public
RandomAccessFile
{
const
std
::
string
filename_
;
// PLEASE NOTE: hFile is expected to be an async handle
// (i.e. opened with FILE_FLAG_OVERLAPPED)
HANDLE
hFile_
;
const
bool
use_os_buffer_
;
bool
read_ahead_
;
...
...
@@ -1225,6 +1244,12 @@ class WinEnv : public Env {
fileFlags
|=
FILE_FLAG_RANDOM_ACCESS
;
}
if
(
!
options
.
use_mmap_reads
)
{
// Open in async mode which makes Windows allow more parallelism even
// if we need to do sync I/O on top of it.
fileFlags
|=
FILE_FLAG_OVERLAPPED
;
}
/// Shared access is necessary for corruption test to pass
// almost all tests would work with a possible exception of fault_injection
HANDLE
hFile
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录