Skip to content

Commit

Permalink
Mark Cache and Env as Send and Sync (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
akrylysov committed Jul 9, 2021
1 parent f00ae8c commit 54cbd34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/db_options.rs
Expand Up @@ -384,6 +384,8 @@ unsafe impl Send for BlockBasedOptions {}
unsafe impl Send for CuckooTableOptions {}
unsafe impl Send for ReadOptions {}
unsafe impl Send for IngestExternalFileOptions {}
unsafe impl Send for Cache {}
unsafe impl Send for Env {}

// Sync is similarly safe for many types because they do not expose interior mutability, and their
// use within the rocksdb library is generally behind a const reference
Expand All @@ -393,6 +395,8 @@ unsafe impl Sync for BlockBasedOptions {}
unsafe impl Sync for CuckooTableOptions {}
unsafe impl Sync for ReadOptions {}
unsafe impl Sync for IngestExternalFileOptions {}
unsafe impl Sync for Cache {}
unsafe impl Sync for Env {}

impl Drop for Options {
fn drop(&mut self) {
Expand Down
11 changes: 8 additions & 3 deletions src/lib.rs
Expand Up @@ -172,9 +172,10 @@ impl fmt::Display for Error {
#[cfg(test)]
mod test {
use super::{
BlockBasedOptions, BoundColumnFamily, ColumnFamily, ColumnFamilyDescriptor, DBIterator,
DBRawIterator, IngestExternalFileOptions, Options, PlainTableFactoryOptions, ReadOptions,
Snapshot, SstFileWriter, WriteBatch, WriteOptions, DB,
BlockBasedOptions, BoundColumnFamily, Cache, ColumnFamily, ColumnFamilyDescriptor,
DBIterator, DBRawIterator, Env, IngestExternalFileOptions, Options,
PlainTableFactoryOptions, ReadOptions, Snapshot, SstFileWriter, WriteBatch, WriteOptions,
DB,
};

#[test]
Expand All @@ -201,6 +202,8 @@ mod test {
is_send::<BoundColumnFamily<'_>>();
is_send::<SstFileWriter>();
is_send::<WriteBatch>();
is_send::<Cache>();
is_send::<Env>();
}

#[test]
Expand All @@ -221,5 +224,7 @@ mod test {
is_sync::<PlainTableFactoryOptions>();
is_sync::<ColumnFamilyDescriptor>();
is_sync::<SstFileWriter>();
is_sync::<Cache>();
is_sync::<Env>();
}
}

0 comments on commit 54cbd34

Please sign in to comment.