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
20b37ffe
Commit
20b37ffe
authored
Nov 05, 2017
by
UncP
Committed by
siddontang
Nov 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
impl Send for rate limiter (#150)
parent
6ddad5cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
rocksdb_options.rs
src/rocksdb_options.rs
+3
-0
test_rate_limiter.rs
tests/test_rate_limiter.rs
+12
-0
No files found.
src/rocksdb_options.rs
View file @
20b37ffe
...
...
@@ -153,6 +153,9 @@ pub struct RateLimiter {
inner
:
*
mut
DBRateLimiter
,
}
unsafe
impl
Send
for
RateLimiter
{
}
unsafe
impl
Sync
for
RateLimiter
{
}
impl
RateLimiter
{
pub
fn
new
(
rate_bytes_per_sec
:
i64
,
refill_period_us
:
i64
,
fairness
:
i32
)
->
RateLimiter
{
let
limiter
=
unsafe
{
...
...
tests/test_rate_limiter.rs
View file @
20b37ffe
...
...
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use
std
::
thread
;
use
rocksdb
::
RateLimiter
;
#[test]
...
...
@@ -37,3 +38,14 @@ fn test_rate_limiter() {
assert_eq!
(
rate_limiter
.get_total_bytes_through
(
total
),
3072
*
1024
);
}
#[test]
fn
test_rate_limiter_sendable
()
{
let
mut
rate_limiter
=
RateLimiter
::
new
(
10
*
1024
*
1024
,
100
*
1000
,
10
);
let
handle
=
thread
::
spawn
(
move
||
{
rate_limiter
.request
(
1024
,
0
);
});
handle
.join
();
}
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