2019-03-27 09:35:09 +00:00
|
|
|
extern crate salsa;
|
|
|
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
2019-03-27 09:44:48 +00:00
|
|
|
#[salsa::query_group(NoSendSyncStorage)]
|
|
|
|
trait NoSendSyncDatabase: salsa::Database {
|
|
|
|
fn no_send_sync_value(&self, key: bool) -> Rc<bool>;
|
|
|
|
fn no_send_sync_key(&self, key: Rc<bool>) -> bool;
|
|
|
|
}
|
2019-03-27 09:35:09 +00:00
|
|
|
|
2020-07-03 10:46:00 +00:00
|
|
|
fn no_send_sync_value(_db: &dyn NoSendSyncDatabase, key: bool) -> Rc<bool> {
|
2019-03-27 09:44:48 +00:00
|
|
|
Rc::new(key)
|
2019-03-27 09:35:09 +00:00
|
|
|
}
|
|
|
|
|
2020-07-03 10:46:00 +00:00
|
|
|
fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Rc<bool>) -> bool {
|
2019-03-27 09:44:48 +00:00
|
|
|
*key
|
2019-03-27 09:35:09 +00:00
|
|
|
}
|
|
|
|
|
2019-03-27 09:44:48 +00:00
|
|
|
#[salsa::database(NoSendSyncStorage)]
|
2019-03-27 09:35:09 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
struct DatabaseImpl {
|
2020-07-02 10:31:02 +00:00
|
|
|
storage: salsa::Storage<Self>,
|
2019-03-27 09:35:09 +00:00
|
|
|
}
|
|
|
|
|
2020-07-02 10:31:02 +00:00
|
|
|
impl salsa::Database for DatabaseImpl {}
|
2019-03-27 09:35:09 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_send_sync() {
|
2019-04-03 14:01:38 +00:00
|
|
|
let db = DatabaseImpl::default();
|
2019-03-27 09:35:09 +00:00
|
|
|
|
2019-03-27 09:44:48 +00:00
|
|
|
assert_eq!(db.no_send_sync_value(true), Rc::new(true));
|
2021-11-01 17:42:03 +00:00
|
|
|
assert!(!db.no_send_sync_key(Rc::new(false)));
|
2019-03-27 09:35:09 +00:00
|
|
|
}
|