From 1e45930150b901fc1d975ae2781bdc4eb5ee987c Mon Sep 17 00:00:00 2001 From: widagdos Date: Sat, 23 Mar 2024 00:09:28 -0700 Subject: 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. --- src/backup.rs | 4 ++++ tests/test_backup.rs | 7 +++++++ 2 files changed, 11 insertions(+) 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 { 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() {} + +#[test] +fn assert_send() { + assert_send_generic::(); +} -- cgit v1.2.3-70-g09d2