Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
7871c0f0
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7871c0f0
编写于
9月 22, 2019
作者:
L
leipeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
async api: refactory: pass key value to callback & future
上级
e930462c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
27 deletion
+34
-27
db/db_impl.cc
db/db_impl.cc
+25
-19
include/rocksdb/db.h
include/rocksdb/db.h
+9
-8
未找到文件。
db/db_impl.cc
浏览文件 @
7871c0f0
...
...
@@ -2896,37 +2896,38 @@ DB::~DB() {}
void
DB
::
GetAsync
(
const
ReadOptions
&
ro
,
ColumnFamilyHandle
*
cfh
,
std
::
string
key
,
std
::
string
*
value
,
std
::
function
<
void
(
const
Status
&
)
>
cb
)
{
GetAsyncCallback
cb
)
{
using
namespace
boost
::
fibers
;
using
std
::
move
;
auto
tls
=
getFiberTLS
();
tls
->
update_fiber_count
(
ro
.
aio_concurrency
);
tls
->
push
([
=
,
key
=
move
(
key
),
cb
=
move
(
cb
)](){
cb
(
this
->
Get
(
ro
,
cfh
,
key
,
value
));
tls
->
push
([
=
,
key
=
move
(
key
),
cb
=
move
(
cb
)]()
mutable
{
auto
s
=
this
->
Get
(
ro
,
cfh
,
key
,
value
);
cb
(
move
(
s
),
move
(
key
),
value
);
});
}
void
DB
::
GetAsync
(
const
ReadOptions
&
ro
,
std
::
string
key
,
std
::
string
*
value
,
std
::
function
<
void
(
const
Status
&
)
>
cb
)
{
GetAsyncCallback
cb
)
{
using
std
::
move
;
GetAsync
(
ro
,
DefaultColumnFamily
(),
move
(
key
),
value
,
move
(
cb
));
}
void
DB
::
GetAsync
(
const
ReadOptions
&
ro
,
ColumnFamilyHandle
*
cfh
,
std
::
string
key
,
std
::
function
<
void
(
const
Status
&
,
std
::
string
*
)
>
cb
)
{
GetAsyncCallback
cb
)
{
using
namespace
boost
::
fibers
;
using
std
::
move
;
auto
tls
=
getFiberTLS
();
tls
->
update_fiber_count
(
ro
.
aio_concurrency
);
tls
->
push
([
=
,
key
=
move
(
key
),
cb
=
move
(
cb
)](){
tls
->
push
([
=
,
key
=
move
(
key
),
cb
=
move
(
cb
)]()
mutable
{
std
::
string
value
;
Status
s
=
this
->
Get
(
ro
,
cfh
,
key
,
&
value
);
cb
(
s
,
&
value
);
cb
(
move
(
s
),
move
(
key
)
,
&
value
);
});
}
void
DB
::
GetAsync
(
const
ReadOptions
&
ro
,
std
::
string
key
,
std
::
function
<
void
(
const
Status
&
,
std
::
string
*
)
>
cb
)
{
GetAsyncCallback
cb
)
{
using
std
::
move
;
GetAsync
(
ro
,
DefaultColumnFamily
(),
move
(
key
),
move
(
cb
));
}
...
...
@@ -2963,41 +2964,46 @@ struct DB_PromisePtr : boost::intrusive_ptr<DB_Promise<T> > {
:
boost
::
intrusive_ptr
<
DB_Promise
<
T
>
>
(
new
DB_Promise
<
T
>
(
k
))
{}
};
future
<
Status
>
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
*>
>
DB
::
GetFuture
(
const
ReadOptions
&
ro
,
ColumnFamilyHandle
*
cfh
,
std
::
string
key
,
std
::
string
*
value
)
{
using
namespace
boost
::
fibers
;
using
std
::
move
;
auto
tls
=
getFiberTLS
();
tls
->
update_fiber_count
(
ro
.
aio_concurrency
);
DB_PromisePtr
<
Status
>
p
(
key
);
future
<
Status
>
fu
=
p
->
pr
.
get_future
();
DB_PromisePtr
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
*>
>
p
(
key
);
auto
fu
=
p
->
pr
.
get_future
();
tls
->
push
([
this
,
ro
,
cfh
,
p
,
value
](){
p
->
pr
.
set_value
(
this
->
Get
(
ro
,
cfh
,
p
->
key
,
value
));
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
*>
result
;
std
::
get
<
0
>
(
result
)
=
this
->
Get
(
ro
,
cfh
,
p
->
key
,
value
);
std
::
get
<
1
>
(
result
)
=
std
::
move
(
p
->
key
);
std
::
get
<
2
>
(
result
)
=
value
;
p
->
pr
.
set_value
(
std
::
move
(
result
));
});
return
fu
;
}
future
<
Status
>
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
*>
>
DB
::
GetFuture
(
const
ReadOptions
&
ro
,
std
::
string
key
,
std
::
string
*
value
)
{
return
GetFuture
(
ro
,
DefaultColumnFamily
(),
std
::
move
(
key
),
value
);
}
future
<
std
::
pair
<
Status
,
std
::
string
>
>
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
>
>
DB
::
GetFuture
(
const
ReadOptions
&
ro
,
ColumnFamilyHandle
*
cfh
,
std
::
string
key
)
{
using
namespace
boost
::
fibers
;
using
std
::
move
;
auto
tls
=
getFiberTLS
();
tls
->
update_fiber_count
(
ro
.
aio_concurrency
);
DB_PromisePtr
<
std
::
pair
<
Status
,
std
::
string
>
>
p
(
key
);
future
<
std
::
pair
<
Status
,
std
::
string
>
>
fu
=
p
->
pr
.
get_future
();
DB_PromisePtr
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
>
>
p
(
key
);
auto
fu
=
p
->
pr
.
get_future
();
tls
->
push
([
this
,
ro
,
cfh
,
p
](){
std
::
pair
<
Status
,
std
::
string
>
result
;
result
.
first
=
this
->
Get
(
ro
,
cfh
,
p
->
key
,
&
result
.
second
);
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
>
result
;
std
::
get
<
0
>
(
result
)
=
this
->
Get
(
ro
,
cfh
,
p
->
key
,
&
std
::
get
<
2
>
(
result
));
std
::
get
<
1
>
(
result
)
=
std
::
move
(
p
->
key
);
p
->
pr
.
set_value
(
std
::
move
(
result
));
});
return
fu
;
}
future
<
std
::
pair
<
Status
,
std
::
string
>
>
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
>
>
DB
::
GetFuture
(
const
ReadOptions
&
ro
,
std
::
string
key
)
{
return
GetFuture
(
ro
,
DefaultColumnFamily
(),
std
::
move
(
key
));
}
...
...
include/rocksdb/db.h
浏览文件 @
7871c0f0
...
...
@@ -374,16 +374,17 @@ class DB {
return
Get
(
options
,
DefaultColumnFamily
(),
key
,
value
);
}
void
GetAsync
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
,
std
::
string
*
value
,
std
::
function
<
void
(
const
Status
&
)
>
);
void
GetAsync
(
const
ReadOptions
&
,
std
::
string
key
,
std
::
string
*
value
,
std
::
function
<
void
(
const
Status
&
)
>
);
void
GetAsync
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
,
std
::
function
<
void
(
const
Status
&
,
std
::
string
*
)
>
);
void
GetAsync
(
const
ReadOptions
&
,
std
::
string
key
,
std
::
function
<
void
(
const
Status
&
,
std
::
string
*
)
>
);
typedef
std
::
function
<
void
(
Status
&&
,
std
::
string
&&
key
,
std
::
string
*
value
)
>
GetAsyncCallback
;
void
GetAsync
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
,
std
::
string
*
value
,
GetAsyncCallback
);
void
GetAsync
(
const
ReadOptions
&
,
std
::
string
key
,
std
::
string
*
value
,
GetAsyncCallback
);
void
GetAsync
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
,
GetAsyncCallback
);
void
GetAsync
(
const
ReadOptions
&
,
std
::
string
key
,
GetAsyncCallback
);
int
WaitAsync
(
int
timeout_us
);
int
WaitAsync
();
future
<
Status
>
GetFuture
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
,
std
::
string
*
value
);
future
<
Status
>
GetFuture
(
const
ReadOptions
&
,
std
::
string
key
,
std
::
string
*
value
);
future
<
std
::
pair
<
Status
,
std
::
string
>
>
GetFuture
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
);
future
<
std
::
pair
<
Status
,
std
::
string
>
>
GetFuture
(
const
ReadOptions
&
,
std
::
string
key
);
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
*>
>
GetFuture
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
,
std
::
string
*
value
);
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
*>
>
GetFuture
(
const
ReadOptions
&
,
std
::
string
key
,
std
::
string
*
value
);
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
>
>
GetFuture
(
const
ReadOptions
&
,
ColumnFamilyHandle
*
,
std
::
string
key
);
future
<
std
::
tuple
<
Status
,
std
::
string
,
std
::
string
>
>
GetFuture
(
const
ReadOptions
&
,
std
::
string
key
);
// If keys[i] does not exist in the database, then the i'th returned
// status will be one for which Status::IsNotFound() is true, and
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录