-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| |_^ (dyn KeyValueDb + 'static)
cannot be shared between threads safely
#6
Comments
Hm, I don't think this is a problem in this crate? |
Can I replace Rc with an Arc pointer for multithreading |
Same question here, maybe Arc will bring more performance loss? |
It's this crate's problem, in my cases
And after checking your code, this problem seem cause by: pub cmp: Rc<Box<dyn Cmp>>,
pub env: Rc<Box<dyn Env>>,
pub log: Option<Rc<RefCell<Logger>>>, So, can we just simply replace Rc with an Arc pointer for multithreading? |
Maybe I'm doing something wrong and it doesn't work this way. I tried simply replace Rc with Arc but rustc still complain me. Test passed version: https://github.com/KunoiSayami/leveldb-rs-arc |
* issue: dermesser/leveldb-rs#6 Signed-off-by: KunoiSayami <i@leanhe.dev>
Well, overall leveldb-rs is made to run on a single thread. So this is intended behavior. I have started work (but not recently continued) on a wrapper suitable for use in asynchronous contexts, which may work for you too (src/asyncdb.rs). |
|
12 | / lazy_static! {
13 | | pub static ref StorageInstanceRef:RwLock = RwLock::new(StorageFactory::default());
14 | | }
| |_^
(dyn KeyValueDb + 'static)
cannot be shared between threads safely|
::: C:\Users\Song.Shang.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\lazy_static-1.4.0\src\inline_lazy.rs:19:20
|
19 | pub struct Lazy<T: Sync>(Cell<Option>, Once);
| ---- required by this bound in
lazy_static::lazy::Lazy
|
= help: the trait
Sync
is not implemented for(dyn KeyValueDb + 'static)
= note: required because of the requirements on the impl of
Sync
forparking_lot::lock_api::RwLock<parking_lot::RawRwLock, (dyn KeyValueDb + 'static)>
= note: required because of the requirements on the impl of
Send
forArc<parking_lot::lock_api::RwLock<parking_lot::RawRwLock, (dyn KeyValueDb + 'static)>>
= note: required because it appears within the type
StorageFactory
= note: required because of the requirements on the impl of
Sync
forparking_lot::lock_api::RwLock<parking_lot::RawRwLock, StorageFactory>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors; 2 warnings emitted
For more information about this error, try
rustc --explain E0277
.error: could not compile
storage
The text was updated successfully, but these errors were encountered: