From afaa2364fc04d98a715160797d5765b4d4810896 Mon Sep 17 00:00:00 2001
From: Vladimir Sedach <vsedach@gmail.com>
Date: Wed, 1 Dec 2010 03:19:30 -0500
Subject: [PATCH] Moved pexec, plet to library.lisp

---
 eager-future2.asd |  3 ++-
 library.lisp      | 26 ++++++++++++++++++++++++++
 make-future.lisp  | 18 ------------------
 3 files changed, 28 insertions(+), 19 deletions(-)
 create mode 100644 library.lisp

diff --git a/eager-future2.asd b/eager-future2.asd
index 133ae4c..fd7c3c1 100644
--- a/eager-future2.asd
+++ b/eager-future2.asd
@@ -6,5 +6,6 @@
   :components ((:file "package")
                (:file "scheduler")
                (:file "make-future")
-               (:file "future"))
+               (:file "future")
+               (:file "library"))
   :depends-on (:bordeaux-threads :trivial-garbage))
diff --git a/library.lisp b/library.lisp
new file mode 100644
index 0000000..ffd344e
--- /dev/null
+++ b/library.lisp
@@ -0,0 +1,26 @@
+(in-package #:eager-future2)
+
+(defmacro pexec (&body body)
+  "A shorthand for (pcall (lambda () ...))."
+  `(pcall (lambda () ,@body)))
+
+(defmacro plet ((&rest bindings) &body body)
+  "Like LET, but all bindings are evaluated asynchronously."
+  (let ((bindings (mapcar (lambda (x) (if (consp x) x (list x nil)))
+                          bindings)))
+    (let ((syms (mapcar (lambda (x) (gensym (string (car x))))
+                        bindings)))
+      `(let ,(loop for (nil exp) in bindings
+                for sym in syms
+                collect `(,sym (pexec ,exp)))
+         (symbol-macrolet ,(loop for (var nil) in bindings
+                              for sym in syms
+                              collect `(,var (yield ,sym)))
+           ,@body)))))
+
+;;(defun pand)
+
+;;(defun por)
+
+(defun select-timeout (timeout &rest futures)
+  (apply #'select (pcall (lambda () (sleep timeout)) :eager) futures))
\ No newline at end of file
diff --git a/make-future.lisp b/make-future.lisp
index 778e2d8..e95e34b 100644
--- a/make-future.lisp
+++ b/make-future.lisp
@@ -69,21 +69,3 @@ The function is called in an unspecified dynamic environment."
     (unless (eq future-type :lazy)
       (schedule-future future future-type))
     future))
-
-(defmacro pexec (&body body)
-  "A shorthand for (pcall (lambda () ...))."
-  `(pcall (lambda () ,@body)))
-
-(defmacro plet ((&rest bindings) &body body)
-  "Like LET, but all bindings are evaluated asynchronously."
-  (let ((bindings (mapcar (lambda (x) (if (consp x) x (list x nil)))
-                          bindings)))
-    (let ((syms (mapcar (lambda (x) (gensym (string (car x))))
-                        bindings)))
-      `(let ,(loop for (nil exp) in bindings
-                for sym in syms
-                collect `(,sym (pexec ,exp)))
-         (symbol-macrolet ,(loop for (var nil) in bindings
-                              for sym in syms
-                              collect `(,var (yield ,sym)))
-           ,@body)))))
-- 
GitLab