Commit 20b37ffe authored by UncP's avatar UncP Committed by siddontang

impl Send for rate limiter (#150)

parent 6ddad5cb
......@@ -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 {
......
......@@ -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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment