diff options
author | widagdos <widagdos@gmail.com> | 2024-03-23 00:09:28 -0700 |
---|---|---|
committer | Zaidoon Abd Al Hadi <43054535+zaidoon1@users.noreply.github.com> | 2024-03-25 04:47:44 -0400 |
commit | 1e45930150b901fc1d975ae2781bdc4eb5ee987c (patch) | |
tree | 50f228c68302b589688ede85749500c873de0f6f | |
parent | 78509aed34668a4f2396754078c3bd63f82072fc (diff) |
Make BackupEngine Send
BackupEngine is a simple pointer wrapper, so it's safe to send to another thread since the underlying RocksDB backup engine is thread-safe.
-rw-r--r-- | src/backup.rs | 4 | ||||
-rw-r--r-- | tests/test_backup.rs | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/backup.rs b/src/backup.rs index 17d0796..2ad37f9 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -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> { diff --git a/tests/test_backup.rs b/tests/test_backup.rs index b1dff2e..5109e52 100644 --- a/tests/test_backup.rs +++ b/tests/test_backup.rs @@ -107,3 +107,10 @@ fn restore_from_backup() { } } } + +fn assert_send_generic<T: Send>() {} + +#[test] +fn assert_send() { + assert_send_generic::<BackupEngine>(); +} |