Add daydream.scm and re-enable some files in Makefile.am.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 31 Jul 2017 15:56:35 +0000 (10:56 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 3 Aug 2017 20:50:18 +0000 (15:50 -0500)
* 8sync/daydream.scm: New file.
* Makefile.am (SOURCES): Adjust for modules which currently do compile.

8sync/daydream.scm [new file with mode: 0644]
Makefile.am

diff --git a/8sync/daydream.scm b/8sync/daydream.scm
new file mode 100644 (file)
index 0000000..291d010
--- /dev/null
@@ -0,0 +1,43 @@
+;;; 8sync --- Asynchronous programming for Guile
+;;; Copyright © 2017 Christopher Allan Webber <cwebber@dustycloud.org>
+;;;
+;;; This file is part of 8sync.
+;;;
+;;; 8sync is free software: you can redistribute it and/or modify it
+;;; under the terms of the GNU Lesser General Public License as
+;;; published by the Free Software Foundation, either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; 8sync is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU Lesser General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with 8sync.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (8sync daydream)
+  #:use-module (8sync)
+  #:use-module (fibers)
+  #:export (daydream))
+
+;;; Daydreaming is a lot like sleeping, except it doesn't block other
+;;; message correspondence.
+
+(define-actor <daydreamer> (<actor>)
+  ((dream daydreamer-dream)))
+
+(define (daydreamer-dream daydreamer message
+                          secs)
+  (sleep secs)
+  ;; We're a single use actor, so we blow up
+  (self-destruct daydreamer)
+  ;; Now reply to the actor's continuation
+  'wake-up)
+
+;; TODO: don't require the actor here
+(define (daydream secs)
+  (define dreamer
+    (create-actor ((@@ (8sync actors) *current-actor*))
+                  <daydreamer>))
+  (<-wait dreamer 'dream secs))
index 2cbd69572ef55aa0620cbcc801ec479c9fb2d7f9..196e8635319856130ff11d30df1d56da8a1f8806 100644 (file)
@@ -47,15 +47,16 @@ godir=$(libdir)/guile/2.2/ccache
 SOURCES =  \
        8sync.scm                                       \
        8sync/actors.scm                                \
-       8sync/inbox.scm
-#      8sync/repl.scm                                  \
+       8sync/daydream.scm                              \
+       8sync/inbox.scm                                 \
+       8sync/repl.scm                                  \
+       8sync/rmeta-slot.scm                            \
+       8sync/systems/irc.scm
 #      8sync/agenda.scm                                \
 #      8sync/debug.scm                                 \
 #      8sync/ports.scm                                 \
-#      8sync/rmeta-slot.scm                            \
 #      8sync/contrib/base64.scm                        \
 #      8sync/contrib/sha-1.scm                         \
-#      8sync/systems/irc.scm                           \
 #      8sync/systems/web.scm                           \
 #      8sync/systems/websocket.scm                     \
 #      8sync/systems/websocket/client.scm              \