equal
deleted
inserted
replaced
202 } |
202 } |
203 |
203 |
204 |
204 |
205 /* database consumer thread */ |
205 /* database consumer thread */ |
206 |
206 |
207 def consumer(db: SQL.Database, cache: XML.Cache): Consumer = new Consumer(db, cache) |
207 def consumer(db: SQL.Database, cache: XML.Cache, progress: Progress = new Progress): Consumer = |
208 |
208 new Consumer(db, cache, progress) |
209 class Consumer private[Export](db: SQL.Database, cache: XML.Cache) |
209 |
|
210 class Consumer private[Export](db: SQL.Database, cache: XML.Cache, progress: Progress) |
210 { |
211 { |
211 private val errors = Synchronized[List[String]](Nil) |
212 private val errors = Synchronized[List[String]](Nil) |
212 |
213 |
213 private val consumer = |
214 private val consumer = |
214 Consumer_Thread.fork_bulk[(Entry, Boolean)](name = "export")( |
215 Consumer_Thread.fork_bulk[(Entry, Boolean)](name = "export")( |
216 consume = |
217 consume = |
217 (args: List[(Entry, Boolean)]) => |
218 (args: List[(Entry, Boolean)]) => |
218 { |
219 { |
219 val results = |
220 val results = |
220 db.transaction { |
221 db.transaction { |
221 for ((entry, strict) <- args) |
222 for ((entry, strict) <- args if !progress.stopped) |
222 yield { |
223 yield { |
223 if (read_name(db, entry.session_name, entry.theory_name, entry.name)) { |
224 if (read_name(db, entry.session_name, entry.theory_name, entry.name)) { |
224 if (strict) { |
225 if (strict) { |
225 val msg = message("Duplicate export", entry.theory_name, entry.name) |
226 val msg = message("Duplicate export", entry.theory_name, entry.name) |
226 errors.change(msg :: _) |
227 errors.change(msg :: _) |
238 |
239 |
239 def shutdown(close: Boolean = false): List[String] = |
240 def shutdown(close: Boolean = false): List[String] = |
240 { |
241 { |
241 consumer.shutdown() |
242 consumer.shutdown() |
242 if (close) db.close() |
243 if (close) db.close() |
243 errors.value.reverse |
244 errors.value.reverse ::: (if (progress.stopped) List("Export stopped") else Nil) |
244 } |
245 } |
245 } |
246 } |
246 |
247 |
247 |
248 |
248 /* abstract provider */ |
249 /* abstract provider */ |