use leveldb::database::kv::KV; use leveldb::options::{Options, WriteOptions}; use utils::{open_database, tmpdir}; #[test] fn access_from_threads() { use std::thread; use std::thread::JoinHandle; let mut opts = Options::new(); opts.create_if_missing = true; let tmp = tmpdir("sharing"); let database = open_database(tmp.path(), true); let _ = (0..10) .map(|i| { let local_db = database.clone(); thread::spawn(move || { let write_opts = WriteOptions::new(); match local_db.put(write_opts, &[i as u8], &[i as u8]) { Ok(_) => {} Err(e) => panic!("failed to write to database: {:?}", e), } }) }) .map(JoinHandle::join) .collect::>(); }