branch: externals/el-job commit 252c669cd5b56bb4ca4c36976cb183ab52e1a608 Author: Martin Edström <meedstro...@gmail.com> Commit: Martin Edström <meedstro...@gmail.com>
Move code around --- el-job.el | 74 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/el-job.el b/el-job.el index 9053098dc3..3ee5a30e87 100644 --- a/el-job.el +++ b/el-job.el @@ -305,7 +305,44 @@ only the max interval between two polls.") "Max amount of processes to spawn for one job. Usually the number of logical cores on your machine minus 1.") -(defvar el-jobs (make-hash-table :test #'eq)) +(defvar el-jobs (make-hash-table :test #'eq) + "Table of all el-job objects.") + +(defun el-job--launch-anonymous ( load + inject-vars + eval-once + funcall + inputs + wrapup ) + "Launch an anonymous job. +See `el-job-launch' for arguments." + (let* ((id (intern (format-time-string "%FT%H%M%S%N"))) + (job (puthash id (el-job--make :id id + :anonymous t + :benchmark nil + :method 'reap + :cores el-job--cores + :wrapup wrapup + :queue inputs) + el-jobs))) + (el-job--spawn-processes job load inject-vars eval-once funcall) + (el-job--exec job))) + +(defmacro el-job--with (job slots &rest body) + "Make SLOTS expand into object accessors for el-job JOB inside BODY. +Cf. `with-slots' in the eieio library, or `let-alist'. + +For clarity inside BODY, each symbol name in SLOTS must be prepended +with one character of your choosing, such as a dot." + (declare (indent 2) (debug ((&rest (symbolp sexp))))) + `(cl-symbol-macrolet + ,(cl-loop + for slot in slots + collect `(,slot (,(intern (concat "el-job:" + (substring (symbol-name slot) 1))) + ,job))) + ,@body)) + (cl-defstruct (el-job (:constructor el-job--make) (:copier nil) (:conc-name el-job:)) @@ -329,41 +366,6 @@ Usually the number of logical cores on your machine minus 1.") queue results) -(defmacro el-job--with (job slots &rest body) - "Make SLOTS expand into object accessors for el-job JOB inside BODY. -Cf. `with-slots' in the eieio library, or `let-alist'. - -For clarity inside BODY, each symbol name in SLOTS must be prepended -with one character of your choosing, such as a dot." - (declare (indent 2) (debug ((&rest (symbolp sexp))))) - `(cl-symbol-macrolet - ,(cl-loop - for slot in slots - collect `(,slot (,(intern (concat "el-job:" - (substring (symbol-name slot) 1))) - ,job))) - ,@body)) - -(defun el-job--launch-anonymous ( load - inject-vars - eval-once - funcall - inputs - wrapup ) - "Launch an anonymous job. -See `el-job-launch' for arguments." - (let* ((id (intern (format-time-string "%FT%H%M%S%N"))) - (job (puthash id (el-job--make :id id - :anonymous t - :benchmark nil - :method 'reap - :cores el-job--cores - :wrapup wrapup - :queue inputs) - el-jobs))) - (el-job--spawn-processes job load inject-vars eval-once funcall) - (el-job--exec job))) - ;;;###autoload (cl-defun el-job-launch (&key load inject-vars