Skip to content
Snippets Groups Projects
Commit 0558f0da authored by Vladimir Sedach's avatar Vladimir Sedach
Browse files

Updated documentation.

parent 2f7849ed
No related branches found
No related tags found
No related merge requests found
...@@ -85,7 +85,7 @@ function force (future &rest values) => nil ...@@ -85,7 +85,7 @@ function force (future &rest values) => nil
macro pexec (&body body) => future macro pexec (&body body) => future
A shorthand for (pcall (lambda () ...)). Shorthand for (pcall (lambda () ...))
macro plet ((&rest bindings) &body body) macro plet ((&rest bindings) &body body)
...@@ -126,3 +126,7 @@ function select-timeout (timeout &rest futures) => future or nil ...@@ -126,3 +126,7 @@ function select-timeout (timeout &rest futures) => future or nil
macro pfuncall (function &rest args) => result macro pfuncall (function &rest args) => result
Evaluates args in parallel before funcalling the given function on them. Evaluates args in parallel before funcalling the given function on them.
function touch (x) => value
If x is a future, yields its value, otherwise returns x.
(in-package #:eager-future2) (in-package #:eager-future2)
(defmacro pexec (&body body) (defmacro pexec (&body body)
"A shorthand for (pcall (lambda () ...))." "Shorthand for (pcall (lambda () ...))"
`(pcall (lambda () ,@body))) `(pcall (lambda () ,@body)))
(defmacro plet ((&rest bindings) &body body) (defmacro plet ((&rest bindings) &body body)
...@@ -78,8 +78,7 @@ elapsed, or the first yieldable future otherwise." ...@@ -78,8 +78,7 @@ elapsed, or the first yieldable future otherwise."
(funcall ,function ,@syms)))) (funcall ,function ,@syms))))
(defun touch (x) (defun touch (x)
"If x is a future, yields its value, otherwise returns x. "If x is a future, yields its value, otherwise returns x."
Borrowed from MultiLisp."
(if (typep x 'future) (if (typep x 'future)
(yield x) (yield x)
x)) x))
...@@ -29,10 +29,14 @@ ...@@ -29,10 +29,14 @@
(with-recursive-lock-held (*thread-counter-lock*) (incf *total-threads*))) (with-recursive-lock-held (*thread-counter-lock*) (incf *total-threads*)))
(defun thread-pool-size () (defun thread-pool-size ()
"Returns the current number of threads in the thread pool. This
number determines the maximum amount of speculative futures that can
be computed at the same time."
(with-recursive-lock-held (*thread-counter-lock*) (with-recursive-lock-held (*thread-counter-lock*)
*total-threads*)) *total-threads*))
(defun advise-thread-pool-size (new-size) (defun advise-thread-pool-size (new-size)
"Attempts to set the amount of threads in the thread pool to given value."
(with-recursive-lock-held (*thread-counter-lock*) (with-recursive-lock-held (*thread-counter-lock*)
(if (< *total-threads* new-size) (if (< *total-threads* new-size)
(loop repeat (- new-size *total-threads*) do (make-pool-thread)) (loop repeat (- new-size *total-threads*) do (make-pool-thread))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment