(define resource%
(class object%
(init-field units)
(define resource #f)
(define/public request
(case-lambda
((units)
(resource-request resource units))
(()
(resource-request resource))))
(define/public relinquish
(case-lambda
((units)
(resource-relinquish resource units))
(()
(resource-relinquish resource))))
(define/public (queue-variable-n)
(set-variable-n (resource-queue resource)))
(define/public (satisfied-variable-n)
(set-variable-n (resource-satisfied resource)))
(super-new)
(set! resource (make-resource units))))
(define-syntax define-resource-class
(syntax-rules ()
((define-resource-class (name superclass-expr)
class-clause
...)
(define name
(class superclass-expr
class-clause
...
(inherit-field resource)
(super-new)
(set! resource (make-resource units)))))
((define-resource-class name
class-clause
...)
(define-process-class (name resource%)
class-clause
...))))