garbage-pools

2021-01-24

GARBAGE-POOLS is Common Lisp re-implementation of the APR Pools for resource management.

Upstream URL

github.com/archimag/garbage-pools

Author

Andrey Moskvitin <archimag@gmail.com>

License

MIT
README
garbage-pools

GARBAGE-POOLS is Common Lisp re-implementation the APR Pools for resource management.

1API

pool
The fundamental pool type.
with-garbage-pool
((&optional (var '*pool*)) &body body)

Performs a series of operations on pool. Return the values returned by the body. Possible use named and unnamed pools.

(with-garbage-pool () (cleanup-register myobj clenup-fun))
(with-garbage-pool (mypool) (cleanup-register myobj clenup-fun mypool))
cleanup-register
(object cleanup-fun &optional (pool *pool*))

Register a function to be called when a pool is cleared. Return object.

(with-garbage-pool ()
  (cleanup-register (cffi:foreign-string-alloc "Hello world") #'cffi:foreign-string-free) ...)
cleanup-pool
(&optional (pool *pool*))

Run all the cleanups and clear pool.

cleanup-object
(object &optional (pool *pool*))

Run the specified cleanup function immediately and unregister it. Use object instead of the object that was registered with the cleanup.

(with-garbage-pool ()
  (let ((%str (cleanup-register (cffi:foreign-string-alloc "Hello world")
                                #'cffi:foreign-string-free)))
    (clenup-object %str)))
cancel-object-cleanup
(object &optional (pool *pool*))

Unregister object from pool without call cleanup function.

(with-garbage-pool ()
  (let ((%str (cleanup-register (cffi:foreign-string-alloc "Hello world")
                                #'cffi:foreign-string-free))) (cancel-object-clenup %str)))
object-register
(object &optional (pool *pool*))

Generic function for object registration without cleanup functions. It is use when cleanup functions possibly determine from type of the object (by default supports only pool and stream types). Return object.

(with-garbage-pool () (let ((stream (object-register (open #P"/tmp/data")))) ...))
defcleanup
(class cleanup-fun)

Bind clenup functions with object type. Necessary for use object-register.

(defcleanup stream #'close)

Dependencies (1)

  • lift

Dependents (2)

  • GitHub
  • Quicklisp