Mercurial Hosting > luan
diff src/luan/modules/lucene/LuceneIndex.java @ 1379:87a3738d7cc5
run_in_transaction
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 24 Jul 2019 11:43:04 -0600 |
parents | 709f7498a363 |
children | bc40bc9aab3a |
line wrap: on
line diff
--- a/src/luan/modules/lucene/LuceneIndex.java Sun Jul 14 22:26:33 2019 -0600 +++ b/src/luan/modules/lucene/LuceneIndex.java Wed Jul 24 11:43:04 2019 -0600 @@ -260,25 +260,26 @@ } } - public void update_in_transaction(LuanFunction fn) throws IOException, LuanException { + public Object run_in_transaction(LuanFunction fn) throws IOException, LuanException { boolean commit = !writeLock.isHeldByCurrentThread(); writeLock.lock(); try { - fn.call(); + Object rtn = fn.call(); if(commit) writer.commit(); + return rtn; } finally { wrote(); writeLock.unlock(); } } - public void run_in_lock(LuanFunction fn) throws IOException, LuanException { + public Object run_in_lock(LuanFunction fn) throws IOException, LuanException { if( writeLock.isHeldByCurrentThread() ) throw new RuntimeException(); writeLock.lock(); try { synchronized(this) { - fn.call(); + return fn.call(); } } finally { wrote();