Macro: IN-TXN

Source

(defmacro in-txn ((txn &key no-sync sync do-commit) &body body)
  (with-gensyms (success return)
    (once-only (txn do-commit)
      `(let ((,return nil)
	     (,success nil))
	(unwind-protect
	     (progn
	       (setq ,return (multiple-value-list
			      (progn
				,@body)))
	       (when ,do-commit
		 (db-txn-commit ,txn
				:no-sync ,no-sync
				:sync ,sync))
	       (setq ,success t)
	       (apply #'values ,return))
	  (if (and ,do-commit
		   (not ,success))
	      (db-txn-abort ,txn)))))))
Source Context