guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-92-gf4e45e


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-92-gf4e45e9
Date: Thu, 26 May 2011 16:16:25 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=f4e45e91f265429ad1c42d3905dd3c05a0bc0924

The branch, stable-2.0 has been updated
       via  f4e45e91f265429ad1c42d3905dd3c05a0bc0924 (commit)
      from  a8952d1fb73218ad2389bb290ebbb737d4f88fce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f4e45e91f265429ad1c42d3905dd3c05a0bc0924
Author: Andy Wingo <address@hidden>
Date:   Thu May 26 18:14:32 2011 +0200

    lazily init futures worker pool
    
    * module/ice-9/futures.scm (%workers, %create-workers!)
      (create-workers!): Define a mechanism to spawn off the future threads
      only when the first future is created.
      (make-future): Call create-workers! here.

-----------------------------------------------------------------------

Summary of changes:
 module/ice-9/futures.scm |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/module/ice-9/futures.scm b/module/ice-9/futures.scm
index 1aebaa6..012ebbf 100644
--- a/module/ice-9/futures.scm
+++ b/module/ice-9/futures.scm
@@ -1,6 +1,6 @@
 ;;; -*- mode: scheme; coding: utf-8; -*-
 ;;;
-;;; Copyright (C) 2010 Free Software Foundation, Inc.
+;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
 ;;;
 ;;; This library is free software; you can redistribute it and/or
 ;;; modify it under the terms of the GNU Lesser General Public
@@ -54,6 +54,7 @@
   "Return a new future for THUNK.  Execution may start at any point
 concurrently, or it can start at the time when the returned future is
 touched."
+  (create-workers!)
   (let ((future (%make-future thunk #f (make-mutex))))
     (register-future! future)
     future))
@@ -145,19 +146,27 @@ touched."
       (- (current-processor-count) 1)
       0))
 
-(define %workers
-  ;; A dock of workers that stay here forever.
-
-  ;; TODO
-  ;; 1. Allocate lazily.
-  ;; 2. Allow the pool to be shrunk, as in libgomp (though that we'd
-  ;;    need semaphores, which aren't yet in libguile!).
-  ;; 3. Provide a `worker-count' fluid.
-  (unfold (lambda (i) (>= i %worker-count))
-          (lambda (i)
-            (call-with-new-thread process-futures))
-          1+
-          0))
+;; A dock of workers that stay here forever.
+
+;; TODO
+;; 1. Allow the pool to be shrunk, as in libgomp (though that we'd
+;;    need semaphores, which aren't yet in libguile!).
+;; 2. Provide a `worker-count' fluid.
+(define %workers '())
+
+(define (%create-workers!)
+  (lock-mutex %futures-mutex)
+  (set! %workers
+        (unfold (lambda (i) (>= i %worker-count))
+                (lambda (i)
+                  (call-with-new-thread process-futures))
+                1+
+                0))
+  (set! create-workers! (lambda () #t))
+  (unlock-mutex %futures-mutex))
+
+(define create-workers!
+  (lambda () (%create-workers!)))
 
 
 ;;;


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]