summaryrefslogtreecommitdiff
path: root/module/srfi/srfi-18.scm
AgeCommit message (Collapse)AuthorFilesLines
2019-11-29Associate #:replace info with modules, not variablesAndy Wingo1-2/+2
* doc/ref/api-modules.texi (Creating Guile Modules): Document #:re-export-and-replace. * module/ice-9/boot-9.scm (module-replacements): New module field. (make-module, make-autoload-interface): Initialize replacements to an empty hash table. (resolve-interface): Propagate replacement info when making custom interfaces. (define-module): Parse a #:re-export-and-replace keyword arg. (define-module*): Handle #:re-export-and-replace. (module-export!, module-re-export!): Add a keyword arg to indicate whether to replace or not. (module-replace!): Call module-export! with #:replace? #t. (duplicate-handlers): Update replace duplicate handler to look for replacement info on the interfaces. * module/srfi/srfi-18.scm (srfi): * module/srfi/srfi-34.scm (srfi): Update to #:re-export-and-replace raise-continuable as raise.
2019-11-14SRFI-18 uses core exceptionsAndy Wingo1-86/+60
* 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.
2018-08-07srfi-18: 'thread-sleep!' timeout-as-a-number is relative.Ludovic Courtès1-3/+3
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-07srfi-18: When timeout is a number, it's a relative number of seconds.Ludovic Courtès1-16/+28
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.
2016-11-05SRFI-18 mutexes are not recursiveAndy Wingo1-8/+1
* module/srfi/srfi-18.scm (make-mutex): Not recursive.
2016-11-05Move more functionality to SRFI-18 mutex-unlock!Andy Wingo1-15/+17
* module/srfi/srfi-18.scm (mutex-unlock!): Implement the ignore-unlock-errors and wait-condition-variable behavior of mutex-unlock! directly, without relying on Guile.
2016-11-05SRFI-18 manages own mutex "abandoned" stateAndy Wingo1-21/+20
* module/srfi/srfi-18.scm (<mutex>, with-thread-mutex-cleanup) (make-mutex, mutex-state, abandon-mutex!, mutex-lock!): Manage "abandoned" bit on Scheme side with no need for thread cleanup handler.
2016-11-04SRFI-18 threads disjoint from guile threadsAndy Wingo1-67/+75
* doc/ref/srfi-modules.texi (SRFI-18 Threads): Update. * module/srfi/srfi-18.scm (<mutex>): Add owner field. (<thread>): New data type. (make-thread): Adapt for boxed threads. (thread-start!, thread-terminate!): Likewise. (mutex-state): Adapt for boxed threads. (mutex-lock!, mutex-unlock!): Update owner field.
2016-11-04srfi-18 condition variables disjointAndy Wingo1-32/+27
* module/srfi/srfi-18.scm (<condition-variable>): New data type. (make-thread): Use srfi-18 interfaces. (mutex-unlock!): Adapt to optional cond argument being disjoint from Guile condition variables. (make-condition-variable, condition-variable-signal!) (condition-variable-broadcast!): Adapt.
2016-11-04Remove export srfi-18 never hadAndy Wingo1-1/+0
* module/srfi/srfi-18.scm (condition-variable-wait!): Remove undefined export.
2016-11-04SRFI-18 mutexes disjoint from Guile mutexesAndy Wingo1-41/+62
* 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-10-31srfi-18: thread-terminate! without cleanup handlersAndy Wingo1-23/+13
* module/srfi/srfi-18.scm (%cancel-sentinel, thread-terminate!): Just use cancel-thread to cause the thread to return a sentinel value. (%timeout-sentinel): Rename from %sentinel. (thread-join!): Adapt and transform %cancel-sentinel to a &terminated-thread-exception.
2016-10-31Trim srfi-18 thread startup machineryAndy Wingo1-10/+6
* module/srfi/srfi-18.scm (make-thread): Use just one cond/mutex pair for signalling in both directions: waiting for launch and waiting for start.
2016-10-31Refactor thread-join! to use optional args.Andy Wingo1-7/+14
* module/srfi/srfi-18.scm (thread-join!): Use optional args. Also don't treat false return values from threads as meaning anything.
2016-10-31Rationalize exception handling in srfi-18Andy Wingo1-44/+38
* module/srfi/srfi-18.scm (make-thread): Inline some helpers, and use just one catch block. (thread->exception): Move up definition. (exception-handler-for-foreign-threads): Use this as the default handler, not the one that squirrels away exceptions in thread->exception. (thread-terminate!): Don't instate an exception handler for the thread cleanup proc.
2016-10-31srfi-18: Avoid call/cc.Andy Wingo1-29/+35
* module/srfi/srfi-18.scm (with-exception-handlers-here): New function. (wrap): Remove. (thread-join!, mutex-lock!): Use with-exception-handlers-here instead of the call/cc+wrap mess.
2016-10-30srfi-18: Inline uses of srfi-18-exception-preserver.Andy Wingo1-16/+13
* module/srfi/srfi-18.scm (srfi-18-exception-preserver): Inline into call sites.
2016-10-30srfi-18: Use srfi-35 conditions.Andy Wingo1-26/+25
* 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-30srfi-18: Use parameters.Andy Wingo1-25/+15
* module/srfi/srfi-18.scm: Use srfi-34 internally with srfi-34: prefix. (current-exception-handler): Be a parameter. (with-exception-handler): Adapt to current-exception-handler change. (thread-join!, mutex-lock!): Adapt to use srfi-34: prefix.
2016-10-30srfi-18: Use lambda* optional arguments.Andy Wingo1-12/+10
* module/srfi/srfi-18.scm (make-mutex, make-condition-variable): Use optional arguments.
2016-10-30srfi-18: Simplify thread-sleep!, thread-terminate!.Andy Wingo1-19/+15
* module/srfi/srfi-18.scm (thread-sleep!): Use `when'. (thread-terminate!): Simplify.
2016-10-30srfi-18: Use `match' in thread-start!.Andy Wingo1-9/+10
* module/srfi/srfi-18.scm (thread-start!): Use `match'.
2016-10-30srfi-18: Improve style.Andy Wingo1-11/+7
* module/srfi/srfi-18.scm (raise): Rely on SRFI-34 to #:replace raise. (make-thread): Use lambda* and when.
2016-10-23Move thread bindings to (ice-9 threads)Andy Wingo1-111/+111
* 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.
2014-04-25Merge branch 'stable-2.0'v2.1.0Mark H Weaver1-4/+4
Conflicts: GUILE-VERSION NEWS guile-readline/ice-9/readline.scm libguile/async.c libguile/backtrace.c libguile/deprecated.h libguile/gc-malloc.c libguile/gdbint.c libguile/init.c libguile/ioext.c libguile/mallocs.c libguile/print.c libguile/rw.c libguile/scmsigs.c libguile/script.c libguile/simpos.c libguile/snarf.h libguile/strports.c libguile/threads.c libguile/vm-i-scheme.c libguile/vm-i-system.c module/srfi/srfi-18.scm test-suite/Makefile.am test-suite/standalone/test-num2integral.c
2014-03-23Calculate usecs correctly in thread-sleep!Nathaniel Alderson1-1/+1
* module/srfi/srfi-18.scm (thread-sleep!): Correctly compute microseconds. * test-suite/tests/srfi-18.test: Add test.
2014-02-27SRFI-18: Export 'current-thread'.Mark H Weaver1-3/+3
Fixes <http://debbugs.gnu.org/16890>. Reported by Xin Wang <dram.wang@gmail.com>. * module/srfi/srfi-18.scm: Reexport 'current-thread'. * THANKS: Add "Xin Wang" to fixes section.
2012-02-24srfi-18 cleanupAndy Wingo1-13/+13
* module/srfi/srfi-18.scm (with-exception-handler): (thread-join!, mutex-lock!, mutex-unlock!): Avoid useless invocations of `apply'.
2010-01-11Remove unused top-level variables.Ludovic Courtès1-2/+1
* module/ice-9/runq.scm (fork-strips): Remove. * module/language/assembly.scm (*block-alignment*): Remove. * module/language/assembly/disassemble.scm (disassemble-objects, simplify): Remove. * module/srfi/srfi-18.scm (mutex-owners): Remove. * module/srfi/srfi-19.scm (leap-year?): Remove. * module/system/base/compile.scm (dsu-sort): Remove. * module/texinfo.scm (ascii->char): Remove. * module/texinfo/html.scm (ignored?): Remove. * module/texinfo/indexing.scm (def-name): Remove. * module/texinfo/plain-text.scm (ignore): Remove.
2009-10-22Fix typos leading to unbound variable references.Ludovic Courtès1-2/+2
* module/ice-9/session.scm (help): Fix unbound reference to `env'. * module/system/vm/program.scm (program-property): Fix typo. * module/system/vm/frame.scm: Add missing `#:use-module (system vm objcode)'. * module/system/repl/command.scm (guile:load): New. (load): Use either `primitive-load' or `load'. * module/srfi/srfi-18.scm (thread-sleep!): Fix typo. * module/srfi/srfi-19.scm: Use `(ice-9 rdelim)'. (date->broken-down-time, priv:year-day, priv:char->int): Fix typo. (time-*->time-*, time-*->time-*!): Fix reference to unbound variable `caller'. * module/oop/goops.scm (bound-check-get): Fix typo. * module/language/glil/compile-assembly.scm (glil->assembly): Fix typo. * module/language/glil.scm (parse-glil): Fix typo. * module/language/ecmascript/base.scm (object->value/string, object->value/number, ->number): Fix typos. * module/language/assembly/disassemble.scm (disassemble-free-vars): Fix typo.
2009-06-17Complete changing license to LGPLv3+Neil Jerram1-1/+1
(Still guile-readline to do, but that will all be GPLv3+.)
2009-05-21fix multiple values returning from srfi-18's `with-exception-handler'Andy Wingo1-2/+4
* module/srfi/srfi-18.scm (with-exception-handler): Hah! Fixed a scurrilous bug in which we assumed that the thunk returned one or more values. Hah.
2009-05-21procedures in "drop" contexts can return unspecified valuesAndy Wingo1-2/+2
* 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...
2008-11-01move scm srfi files to module/srfi, and compile them.Andy Wingo1-0/+382
* .gitignore: Add gdb-pre-inst-guile. * configure.in: Add module/srfi/Makefile. * module/Makefile.am: Add srfi/. * module/srfi/: SRFI scheme files moved here, and compiled. * srfi/Makefile.am: Remove the bits about the scheme files.