;; ;; Kawa module for Terracotta ;; ;; Author: Krzysztof Kliƛ ;; ;; Start Kawa with: ;; java -Xbootclasspath/p:[terracotta boot jar] -Dtc.install-root=[terracotta install dir] -Dtc.config=tc-config.xml -jar kawa.jar ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU Lesser General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU Lesser General Public License for more details. ;; ;; You should have received a copy of the GNU Lesser General Public License ;; along with this program. If not, see . ;; (define-namespace ManagerUtil ) (define TC_READ_LOCK 1) (define TC_WRITE_LOCK 2) ;; ;; Create Terracotta shared root object ;; ;; @param Name: object name (string) ;; @param Object: java.lang.Object to share ;; (define (create-root Name Object) (begin (ManagerUtil:beginLock Name TC_WRITE_LOCK) (let ((ob (ManagerUtil:lookupOrCreateRoot Name Object))) (begin (ManagerUtil:commitLock Name) ob)))) ;; ;; Execute expression in Terracotta synchronized context with read lock ;; ;; @param Exp: lambda expression ;; @param Object: java.lang.Object shared with Terracotta ;; (define (sync-read Exp Object) (begin (ManagerUtil:monitorEnter Object TC_READ_LOCK) (let ((res (Exp))) (begin (ManagerUtil:monitorExit Object) res)))) ;; ;; Execute expression in Terracotta synchronized context with write lock ;; ;; @param Exp: lambda expression ;; @param Object: java.lang.Object shared with Terracotta ;; (define (sync-write Exp Object) (begin (ManagerUtil:monitorEnter Object TC_WRITE_LOCK) (let ((res (Exp))) (begin (ManagerUtil:monitorExit Object) res))))