Skip to content

Commit

Permalink
Make BackupEngine Send
Browse files Browse the repository at this point in the history
BackupEngine is a simple pointer wrapper, so it's safe to send to another thread since the underlying RocksDB backup engine is thread-safe.
  • Loading branch information
widagdos authored and zaidoon1 committed Mar 25, 2024
1 parent 78509ae commit 1e45930
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ pub struct RestoreOptions {
inner: *mut ffi::rocksdb_restore_options_t,
}

// BackupEngine is a simple pointer wrapper, so it's safe to send to another thread
// since the underlying RocksDB backup engine is thread-safe.
unsafe impl Send for BackupEngine {}

impl BackupEngine {
/// Open a backup engine with the specified options and RocksDB Env.
pub fn open(opts: &BackupEngineOptions, env: &Env) -> Result<Self, Error> {
Expand Down
7 changes: 7 additions & 0 deletions tests/test_backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,10 @@ fn restore_from_backup() {
}
}
}

fn assert_send_generic<T: Send>() {}

#[test]
fn assert_send() {
assert_send_generic::<BackupEngine>();
}

0 comments on commit 1e45930

Please sign in to comment.