Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
rust-rocksdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
rust-rocksdb
Commits
95d3e971
Commit
95d3e971
authored
Feb 17, 2017
by
zhangjinpeng1987
Committed by
siddontang
Feb 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support pause and continue bg threads (#13)
parent
5c5cf595
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
0 deletions
+55
-0
c.cc
librocksdb_sys/crocksdb/c.cc
+8
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+6
-0
lib.rs
librocksdb_sys/src/lib.rs
+2
-0
rocksdb.rs
src/rocksdb.rs
+39
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
95d3e971
...
...
@@ -531,6 +531,14 @@ void crocksdb_close(crocksdb_t* db) {
delete
db
;
}
void
crocksdb_pause_bg_work
(
crocksdb_t
*
db
)
{
db
->
rep
->
PauseBackgroundWork
();
}
void
crocksdb_continue_bg_work
(
crocksdb_t
*
db
)
{
db
->
rep
->
ContinueBackgroundWork
();
}
crocksdb_t
*
crocksdb_open_column_families
(
const
crocksdb_options_t
*
db_options
,
const
char
*
name
,
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
95d3e971
...
...
@@ -202,6 +202,12 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_column_family_handle_destroy(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_close
(
crocksdb_t
*
db
);
// This function will wait until all currently running background processes
// finish. After it returns, no background process will be run until
// crocksdb_continue_bg_work is called
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_pause_bg_work
(
crocksdb_t
*
db
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_continue_bg_work
(
crocksdb_t
*
db
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_put
(
crocksdb_t
*
db
,
const
crocksdb_writeoptions_t
*
options
,
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
,
char
**
errptr
);
...
...
librocksdb_sys/src/lib.rs
View file @
95d3e971
...
...
@@ -352,6 +352,8 @@ extern "C" {
kLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_close
(
db
:
*
mut
DBInstance
);
pub
fn
crocksdb_pause_bg_work
(
db
:
*
mut
DBInstance
);
pub
fn
crocksdb_continue_bg_work
(
db
:
*
mut
DBInstance
);
pub
fn
crocksdb_destroy_db
(
options
:
*
const
DBOptions
,
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
);
...
...
src/rocksdb.rs
View file @
95d3e971
...
...
@@ -423,6 +423,18 @@ impl DB {
Ok
(
cfs
)
}
pub
fn
pause_bg_work
(
&
self
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_pause_bg_work
(
self
.inner
);
}
}
pub
fn
continue_bg_work
(
&
self
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_continue_bg_work
(
self
.inner
);
}
}
pub
fn
path
(
&
self
)
->
&
str
{
&
self
.path
}
...
...
@@ -1219,6 +1231,9 @@ mod test {
use
std
::
fs
;
use
std
::
path
::
Path
;
use
std
::
str
;
use
std
::
string
::
String
;
use
std
::
sync
::
*
;
use
std
::
thread
;
use
super
::
*
;
use
tempdir
::
TempDir
;
...
...
@@ -1465,6 +1480,30 @@ mod test {
let
a
=
db
.get_cf
(
cf_handle
,
b
"a"
);
assert
!
(
a
.unwrap
()
.is_none
());
}
#[test]
fn
test_pause_bg_work
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_pause_bg_work"
)
.expect
(
""
);
let
db
=
DB
::
open_default
(
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
Arc
::
new
(
db
);
let
db1
=
db
.clone
();
let
builder
=
thread
::
Builder
::
new
()
.name
(
String
::
from
(
"put-thread"
));
let
h
=
builder
.spawn
(
move
||
{
db1
.put
(
b
"k1"
,
b
"v1"
)
.unwrap
();
db1
.put
(
b
"k2"
,
b
"v2"
)
.unwrap
();
db1
.flush
(
true
)
.unwrap
();
db1
.compact_range
(
None
,
None
);
})
.unwrap
();
// Wait until all currently running background processes finish.
db
.pause_bg_work
();
assert_eq!
(
db
.get_property_int
(
"rocksdb.num-running-compactions"
)
.unwrap
(),
0
);
assert_eq!
(
db
.get_property_int
(
"rocksdb.num-running-flushes"
)
.unwrap
(),
0
);
db
.continue_bg_work
();
h
.join
()
.unwrap
();
}
}
#[test]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment