From 698ca72238fc8c3a7e40df001fd29a0d99d5632c Mon Sep 17 00:00:00 2001 From: Shinmera Date: Fri, 1 Sep 2023 10:44:52 +0200 Subject: [PATCH] Start speccing this out. --- resource.lisp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/resource.lisp b/resource.lisp index fb383b718..1d54715ce 100644 --- a/resource.lisp +++ b/resource.lisp @@ -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)