Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (22 sloc) 898 Bytes
(in-package :pcall)
(defun pcall (thunk)
"Call a thunk in parallel. Returns a task that can be joined. When
an exclusive is given, the task will only run when no other tasks with
that exclusive are running."
(let ((task (make-instance 'task :thunk thunk)))
(queue-push task (pool-queue *pool*))
(unless (pool-threads *pool*)
(defmacro pexec (&body body)
"Shorthand for pcall."
`(pcall (lambda () ,@body)))
(defmacro plet ((&rest bindings) &body body)
(let ((syms (mapcar (lambda (x) (gensym (string (car x)))) bindings)))
`(let ,(loop :for (nil val) :in bindings
:for sym :in syms
:collect `(,sym (pexec ,val)))
(symbol-macrolet ,(loop :for (var nil) :in bindings
:for sym :in syms
:collect `(,var (join ,sym)))
Something went wrong with that request. Please try again.