Skip to content

Commit f6daf75

Browse files
committed
---
yaml --- r: 64639 b: refs/heads/snap-stage3 c: d5803e6 h: refs/heads/master i: 64637: f3dc6c9 64635: 7237473 64631: dceb77a 64623: 031a960 64607: 610c696 64575: b4c75a9 64511: 73dd451 v: v3
1 parent 6cd06fc commit f6daf75

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 48dd72888c67e4afa193565ed288e6351253bf29
4+
refs/heads/snap-stage3: d5803e67eecda097932424a6c7b52cd1addd76b9
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/workcache.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use digest::DigestUtil;
1515
use json;
1616
use sha1::Sha1;
1717
use serialize::{Encoder, Encodable, Decoder, Decodable};
18+
use arc::RWARC;
1819
use treemap::TreeMap;
1920

2021
use std::cell::Cell;
@@ -123,7 +124,7 @@ struct Database {
123124
}
124125

125126
impl Database {
126-
pub fn prepare(&mut self,
127+
pub fn prepare(&self,
127128
fn_name: &str,
128129
declared_inputs: &WorkMap)
129130
-> Option<(WorkMap, WorkMap, ~str)> {
@@ -161,7 +162,7 @@ impl Logger {
161162
}
162163
163164
struct Context {
164-
db: @mut Database,
165+
db: RWARC<Database>,
165166
logger: @mut Logger,
166167
cfg: @json::Object,
167168
freshness: TreeMap<~str,@fn(&str,&str)->bool>
@@ -214,7 +215,7 @@ fn digest_file(path: &Path) -> ~str {
214215
}
215216
216217
impl Context {
217-
pub fn new(db: @mut Database, lg: @mut Logger, cfg: @json::Object)
218+
pub fn new(db: RWARC<Database>, lg: @mut Logger, cfg: @json::Object)
218219
-> Context {
219220
Context {
220221
db: db,
@@ -290,7 +291,9 @@ impl TPrep for Prep {
290291
&self, blk: ~fn(&Exec) -> T) -> Work<T> {
291292
let mut bo = Some(blk);
292293

293-
let cached = self.ctxt.db.prepare(self.fn_name, &self.declared_inputs);
294+
let cached = do self.ctxt.db.read |db| {
295+
db.prepare(self.fn_name, &self.declared_inputs)
296+
};
294297

295298
match cached {
296299
Some((ref disc_in, ref disc_out, ref res))
@@ -346,12 +349,13 @@ fn unwrap<T:Send +
346349
let s = json_encode(&v);
347350

348351
let p = &*ww.prep;
349-
let db = p.ctxt.db;
350-
db.cache(p.fn_name,
351-
&p.declared_inputs,
352-
&exe.discovered_inputs,
353-
&exe.discovered_outputs,
354-
s);
352+
do p.ctxt.db.write |db| {
353+
db.cache(p.fn_name,
354+
&p.declared_inputs,
355+
&exe.discovered_inputs,
356+
&exe.discovered_outputs,
357+
s);
358+
}
355359
v
356360
}
357361
}
@@ -361,9 +365,9 @@ fn unwrap<T:Send +
361365
fn test() {
362366
use std::io::WriterUtil;
363367

364-
let db = @mut Database { db_filename: Path("db.json"),
365-
db_cache: TreeMap::new(),
366-
db_dirty: false };
368+
let db = RWARC(Database { db_filename: Path("db.json"),
369+
db_cache: TreeMap::new(),
370+
db_dirty: false });
367371
let lg = @mut Logger { a: () };
368372
let cfg = @HashMap::new();
369373
let cx = @Context::new(db, lg, cfg);

0 commit comments

Comments
 (0)