Coverage report: /home/ati/workspace/perec/persistence/transaction.lisp

KindCoveredAll%
expression2929100.0
branch46 66.7
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;; -*- mode: Lisp; Syntax: Common-Lisp; -*-
2
 ;;;
3
 ;;; Copyright (c) 2006 by the authors.
4
 ;;;
5
 ;;; See LICENCE for details.
6
 
7
 (in-package :cl-perec)
8
 
9
 ;;; with-database, open-database, close-database, with-transaction, with-transaction*, begin, commit, rollback are all inherited from cl-rdbms
10
 
11
 (defun transaction-of (object)
12
   "Returns the transaction to which the object is currently attached to or nil if the object is not known to be part of any ongoing transaction."
13
   (awhen (slot-value object 'transaction)
14
     (weak-pointer-value it)))
15
 
16
 (defun (setf transaction-of) (transaction object)
17
   "Attaches the object to a different transaction."
18
   (assert (or (not transaction)
19
               (not (transaction-of object))))
20
   (setf (slot-value object 'transaction)
21
         (awhen transaction
22
           (make-weak-pointer transaction))))
23
 
24
 (defun instance-in-transaction-p (object)
25
   "Returns true iff the object is attached to a transaction which is in progress."
26
   (awhen (transaction-of object)
27
     (transaction-in-progress-p it)))
28
 
29
 (defun instance-in-current-transaction-p (object)
30
   "Returns true iff the object is attached to the current transaction which is in progress."
31
   (and (in-transaction-p)
32
        (eq (transaction-of object) *transaction*)))