Skip to content

Commit

Permalink
Start speccing this out.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Sep 1, 2023
1 parent 294718d commit 698ca72
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions resource.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@
(defgeneric allocate (resource))
(defgeneric deallocate (resource))
(defgeneric allocated-p (resource))
(defgeneric load (resource))

(defmethod load ((resource resource))
(defmethod load :around ((resource resource))
(unless (allocated-p resource)
(v:trace :trial.resource "Loading ~a" resource)
(allocate resource)))
(allocate resource))
#-trial-release
(v:trace :trial.resource "Loading ~a" resource)
(call-next-method)
resource)

(defmethod allocate :around ((resource resource))
#-trial-release
(when (allocated-p resource)
(error "Resource ~s is already allocated." resource))
#-trial-release
(v:trace :trial.resource "Allocating ~a" resource)
(call-next-method)
resource)

(defmethod deallocate :around ((resource resource))
#-trial-release
(unless (allocated-p resource)
(error "Resource ~s is already deallocated." resource))
#-trial-release
(v:trace :trial.resource "Deallocating ~a" resource)
(call-next-method)
resource)
Expand Down

0 comments on commit 698ca72

Please sign in to comment.