1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-21 11:10:21 +02:00

Move thread bindings to (ice-9 threads)

* libguile/init.c (scm_i_init_guile): Don't call scm_init_thread_procs.
* libguile/threads.c (scm_init_ice_9_threads): Rename from
  scm_init_thread_procs, make static.
  (scm_init_threads): Register scm_init_thread_procs extension.
* libguile/threads.h (scm_init_thread_procs): Remove decl.
* module/ice-9/boot-9.scm: Load (ice-9 threads), so that related side
  effects occur early.
* module/ice-9/deprecated.scm (define-deprecated): Fix to allow
  deprecated bindings to appear in operator position.  Export deprecated
  bindings.
  (define-deprecated/threads, define-deprecated/threads*): Trampoline
  thread bindings to (ice-9 threads).
* module/ice-9/futures.scm: Use ice-9 threads.
* module/ice-9/threads.scm: Load scm_init_ice_9_threads extension.
  Reorder definitions and imports so that the module circularity
  with (ice-9 futures) continues to work.
* module/language/cps/intmap.scm:
* module/language/cps/intset.scm:
* module/language/tree-il/primitives.scm: Use (ice-9 threads).
* module/language/cps/reify-primitives.scm: Reify current-thread
  in (ice-9 threads) module.
* module/srfi/srfi-18.scm: Use ice-9 threads with a module prefix, and
  adapt all users.  Use proper keywords in module definition form.
* test-suite/tests/filesys.test (test-suite):
* test-suite/tests/fluids.test (test-suite):
* test-suite/tests/srfi-18.test: Use ice-9 threads.
* NEWS: Add entry.
* doc/ref/api-scheduling.texi (Threads): Update.
* doc/ref/posix.texi (Processes): Move current-processor-count and
  total-processor-count docs to Threads.
This commit is contained in:
Andy Wingo 2016-10-23 20:28:48 +02:00
parent 56b490a4dd
commit d74e0fed0d
18 changed files with 328 additions and 202 deletions

View file

@ -19,6 +19,7 @@
(define-module (test-suite test-filesys)
#:use-module (test-suite lib)
#:use-module (test-suite guile-test)
#:use-module (ice-9 threads)
#:use-module (ice-9 match)
#:use-module (rnrs io ports)
#:use-module (rnrs bytevectors))

View file

@ -18,8 +18,9 @@
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-suite test-fluids)
:use-module (test-suite lib)
:use-module (system base compile))
#:use-module (ice-9 threads)
#:use-module (test-suite lib)
#:use-module (system base compile))
(define exception:syntax-error

View file

@ -18,6 +18,7 @@
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-suite test-srfi-18)
#:use-module ((ice-9 threads) #:prefix threads:)
#:use-module (test-suite lib))
;; two expressions so that the srfi-18 import is in effect for expansion
@ -43,9 +44,9 @@
(with-test-prefix "make-thread"
(pass-if "make-thread creates new thread"
(let* ((n (length (all-threads)))
(let* ((n (length (threads:all-threads)))
(t (make-thread (lambda () 'foo) 'make-thread-1))
(r (> (length (all-threads)) n)))
(r (> (length (threads:all-threads)) n)))
(thread-terminate! t) r)))
(with-test-prefix "thread-name"
@ -110,7 +111,7 @@
(pass-if "termination destroys non-started thread"
(let ((t (make-thread (lambda () 'nothing) 'thread-terminate-1))
(num-threads (length (all-threads)))
(num-threads (length (threads:all-threads)))
(success #f))
(thread-terminate! t)
(with-exception-handler
@ -375,7 +376,8 @@
(mutex-unlock! m1)))
(dec-sem! (lambda ()
(mutex-lock! m1)
(while (eqv? sem 0) (wait-condition-variable c1 m1))
(while (eqv? sem 0)
(threads:wait-condition-variable c1 m1))
(set! sem (- sem 1))
(mutex-unlock! m1)))
(t1 (make-thread (lambda ()
@ -449,13 +451,13 @@
h2 (lambda ()
(mutex-lock! m)
(condition-variable-signal! c)
(wait-condition-variable c m)
(threads:wait-condition-variable c m)
(and (eq? (current-exception-handler) h2)
(mutex-unlock! m)))))
'current-exception-handler-4)))
(mutex-lock! m)
(thread-start! t)
(wait-condition-variable c m)
(threads:wait-condition-variable c m)
(and (eq? (current-exception-handler) h1)
(condition-variable-signal! c)
(mutex-unlock! m)