Mercurial Hosting > luan
changeset 1377:4c9691d6288f
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 14 Jul 2019 00:43:45 -0600 |
parents | ba1b4583c2d5 |
children | a503be8b8dce |
files | src/luan/modules/Thread.luan src/luan/modules/lucene/Lucene.luan |
diffstat | 2 files changed, 5 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/Thread.luan Thu Jul 11 23:30:55 2019 -0600 +++ b/src/luan/modules/Thread.luan Sun Jul 14 00:43:45 2019 -0600 @@ -83,16 +83,11 @@ end -local backup_lock = ThreadLuan.backupLock.readLock() local run_in_lock = ThreadLuan.runInLock - Thread.run_in_lock = run_in_lock +Thread.backup_read_lock = ThreadLuan.backupLock.readLock() Thread.backup_write_lock = ThreadLuan.backupLock.writeLock() -function Thread.run_for_backup(fn) - return run_in_lock(backup_lock,fn) -end - function Thread.new_synchronizer() local lock = ReentrantLock.new()
--- a/src/luan/modules/lucene/Lucene.luan Thu Jul 11 23:30:55 2019 -0600 +++ b/src/luan/modules/lucene/Lucene.luan Sun Jul 14 00:43:45 2019 -0600 @@ -12,7 +12,8 @@ local matches = String.matches or error() local Thread = require "luan:Thread.luan" local schedule = Thread.schedule or error() -local run_for_backup = Thread.run_for_backup or error() +local run_in_lock = Thread.run_in_lock or error() +local backup_read_lock = Thread.backup_read_lock or error() local Time = require "luan:Time.luan" local Rpc = require "luan:Rpc.luan" local LuceneIndex = require "java:luan.modules.lucene.LuceneIndex" @@ -141,10 +142,8 @@ local lucene_dir = index.dir local function backup() if backup_dir.last_modified() < lucene_dir.last_modified() then - run_for_backup(function() - index.backup_to(backup_dir) - logger.info "backup" - end) + run_in_lock(backup_read_lock, index.backup_to,backup_dir) + logger.info "backup" end end schedule( backup, {