1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

14 commits

Author SHA1 Message Date
Andy Wingo
95efe14e44 SRFI-18 uses core exceptions
* module/ice-9/boot-9.scm (exception-kind, exception-args): Export.
* module/ice-9/exceptions.scm (exception-kind, exception-args):
  Re-export.
* module/srfi/srfi-18.scm: Rewrite exception support in terms of core
  exceptions, not SRFI-34/35.
* test-suite/tests/srfi-18.test: Since Guile doesn't expose the current
  exception handler as such, SRFI-18 captures it using delimited
  continuations.  This means that we can't compare the result
  of (current-exception-handler) with the installed handler using eq?,
  even though the procedures are indeed equivalent.  So, instead test
  handler behavior.
2019-11-14 16:33:10 +01:00
Ludovic Courtès
898d97d440 srfi-18: 'thread-sleep!' timeout-as-a-number is relative.
This is a followup to <https://bugs.gnu.org/29704>.

* module/srfi/srfi-18.scm (thread-sleep!): When TIMEOUT is a number,
keep it as-is.
* test-suite/tests/srfi-18.test ("thread sleep with number"): Pass 0 as
the timeout.
("thread sleeps fractions of a second"): Pass 0.5 as the timeout.
2018-08-07 11:40:40 +02:00
Ludovic Courtès
cac14ad34d srfi-18: When timeout is a number, it's a relative number of seconds.
Fixes <https://bugs.gnu.org/29704>.
Reported by David Beswick <dlbeswick@gmail.com>.

* module/srfi/srfi-18.scm (timeout->absolute-time): New procedure.
(mutex-lock!): Use it in 'thread:lock-mutex' call.
(mutex-unlock!): Use it.
* test-suite/tests/srfi-18.test ("mutex-lock! returns false on timeout")
("mutex-lock! returns true when lock obtained within timeout")
("recursive lock waits")
("mutex unlock is false when condition times out"): Adjust cases where
the 'timeout' parameter is a number so that it's a relative number.
2018-08-07 11:40:31 +02:00
Andy Wingo
f1f68fffb1 Recursively locking a SRFI-18 mutex blocks
* libguile/threads.c (fat_mutex_lock): allow-external-unlock mutexes
  can't be recursive, but a recursive lock attempt can be unblocked by
  an external thread, so these mutexes shouldn't throw an error on
  recursive lock attempts.
* test-suite/tests/srfi-18.test: Add tests.
2016-11-05 10:30:54 +01:00
Andy Wingo
2559631869 SRFI-18 mutexes disjoint from Guile mutexes
* module/srfi/srfi-18.scm (<mutex>): Define as a wrapper type around
  Guile mutexes.
  (thread-mutexes): New variable.
  (with-thread-mutex-cleanup): New facility to abandon mutexes on
  SRFI-18 thread exit.  Not yet used.
  (make-thread): Use SRFI-18 interfaces.
  (make-mutex): Reimplement for our boxed mutexes.
  (mutex-state): Adapt.
  (mutex-lock!): Adapt.
  (mutex-unlock!): Adapt.
* test-suite/tests/srfi-18.test: Don't assume that SRFI-18 mutexes are
  the same as Guile mutexes.
2016-11-04 20:17:58 +01:00
Andy Wingo
177a058a40 srfi-18: Use srfi-35 conditions.
* module/srfi/srfi-18.scm: Use srfi-35 conditions instead of our
  home-grown equivalent system.
  (thread-exception-handlers): Remove unused table.
  (srfi-18-exception-handler): Always capture key consed to args; no
  special case for bare key.
* test-suite/tests/srfi-18.test (provided?): Adapt to reason always
  being key+args.
2016-10-30 22:30:21 +01:00
Andy Wingo
d74e0fed0d 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.
2016-10-23 22:29:44 +02:00
Nathaniel Alderson
8d124d2077 Calculate usecs correctly in thread-sleep!
* module/srfi/srfi-18.scm (thread-sleep!): Correctly compute
  microseconds.

* test-suite/tests/srfi-18.test: Add test.
2014-03-23 21:58:54 +01:00
Andy Wingo
a850c3ccc4 srfi-18 test fix
* test-suite/tests/srfi-18.test: Enclose the tests in a begin instead of
  an and.  Before, they were not being run, for some reason I don't
  fully understand.
2012-02-24 20:01:47 +01:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Andy Wingo
30a5e062d0 procedures in "drop" contexts can return unspecified values
* module/language/tree-il/compile-glil.scm (flatten): For applications in
  "drop" context, allow the procedure to return unspecified values
  (including 0 values).

* test-suite/tests/tree-il.test ("application"): Adapt test.

* module/srfi/srfi-18.scm (wrap): Clarify.

* test-suite/tests/srfi-18.test: Fix so that the expression importing
  srfi-18 is expanded before the tests. However the tests are still
  failing, something about 0-valued returns...
2009-05-21 17:22:58 +02:00
Julian Graham
d0b6ad3491 Raise error on SRFI-18 load if Guile built without threading support
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2008-08-30 21:08:50 +02:00
Ludovic Courtès
70eca63557 Fix builds `--without-threads'. 2008-08-27 23:05:44 +02:00
Julian Graham
b046219e51 Scheme SRFI-18 implementation and tests file 2008-05-24 10:44:09 +01:00