emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNU ELPA] New package: tam


From: Lynn Winebarger
Subject: [GNU ELPA] New package: tam
Date: Sun, 17 Sep 2023 22:28:56 -0400

I'd like to submit "tam" (table allocation manager) for inclusion in
GNU ELPA.  The source is available at
https://github.com/owinebar/emacs-table-allocation-manager

tam provides functions to track the (manual) allocation of a fixed
number of resources to specific objects.  All the data structures of
the table are fixed at initialization, so that adding or removing a
particular object should not provoke a garbage collection in any
obvious way.  The allocation and deallocation are meant for use in
process sentinels and the like.

I have previously implemented some of the functionality of this
package in a package async-job-queue on MELPA.  However, since that
work cannot be assigned to the FSF, I am writing a more general
purpose async job scheduler from scratch.  In particular, the
scheduler will provide a facility for users to set a maximum number of
async processes to run simultaneously, then manage the assignment of
those process slots to jobs.  The tam functions provide a generic way
to manage that resource allocation in process sentinels.  tam.el was
created on September 15, 2023.

;;; tam.el --- Manage use of slots in a fixed size table  -*-
lexical-binding: t; -*-
;;; Commentary:

;; Table Allocation Manager
;; Provides an interface to managing the usage of the slots in a fixed size
;; table.  All allocation is done during initialization to avoid triggering
;; garbage collection during allocation/free operations.

;;  API:
;;
;;  (tam-create-table N) => table of size N
;;  (tam-table-fullp TABLE) => nil unless TABLE is full
;;  (tam-table-emptyp TABLE) => nil unless TABLE is empty
;;  (tam-table-size TABLE) => number of slots in TABLE
;;  (tam-table-used TABLE) => number of slots of TABLE in use
;;  (tam-table-get TABLE IDX) => contents of TABLE slot at index IDX
;;  (tam-allocate TABLE OBJ) =>
;;      if not full, assigns OBJ to contents of a free slot in TABLE,
;;                   and returns the index of the slot
;;      if full, returns nil
;;  (tam-free TABLE INDEX) =>
;;      if slot at INDEX of TABLE is in use, move to the free list and
;;              return the object formerly held by the slot
;;      if slot is already free, signal an error
;;  (tam-table-free-list TABLE) => list of free indices in TABLE
;;  (tam-table-live-list TABLE) => list of in-use indices in TABLE

Thanks,
Lynn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]