If `join-thread' timeout, the thread mutex is not unlocked, resulting in
deadlock to the next call to it or deadlock of the thread itself when it
terminates.
Thus, always unlock the mutex.
Fixes <https://bugs.gnu.org/55356>.
* module/ice-9/threads.scm (join-thread): Always unlock thread mutex.
* test-suite/tests/threads.test (join-thread): New test to ensure the
mutex is released.
* NEWS: Update.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Fixes <https://bugs.gnu.org/62691>.
Reported by Михаил Бахтерев <mike.bakhterev@gmail.com>.
* module/ice-9/threads.scm (call-with-new-thread): Do not use 'set!'
to set object properties while the calling thread is waiting on the
new thread to initialize.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Fixes <https://bugs.gnu.org/31878>.
* module/ice-9/boot-9.scm (call-with-module-autoload-lock): New procedure.
(try-module-autoload): Wrap body in 'call-with-module-autoload-lock'.
* module/ice-9/threads.scm: Set (@ (guile) call-with-module-autoload-lock).
* libguile/threads.c (really_launch): Start threads with asyncs
blocked.
* module/ice-9/threads.scm (call-with-new-thread): Unblock asyncs once
we have the bookkeeping sorted out. Don't use
with-continuation-barrier; it's not needed. Print nice thread
backtraces.
* module/ice-9/threads.scm (join-thread): Implement in Scheme.
(call-with-new-thread): Arrange to record values in a weak table and
signal the join cond.
(with-mutex): Move up definition; call-with-new-thread needs it. (How
was this working before?)
* libguile/threads.c (guilify_self_1, guilify_self_2, do_thread_exit):
Remove join queue management.
* libguile/threads.c (scm_join_thread, scm_join_thread_timed): Call out
to Scheme.
(scm_init_ice_9_threads): Capture join-thread var.
* module/ice-9/threads.scm (cancel-tag): New variable.
(cancel-thread): New Scheme function.
(call-with-new-thread): Install a prompt around the thread.
* libguile/threads.h (scm_i_thread): Remove cancelled member.
* libguile/threads.c (scm_cancel_thread): Call out to Scheme. Always
available, and works on the current thread too.
(scm_set_thread_cleanup_x, scm_thread_cleanup): Adapt.
(scm_init_ice_9_threads): Capture cancel-thread var.
* doc/ref/api-scheduling.texi (Threads): Update.
* NEWS: Update.
This allows it to actually use all CPU cores, instead of having the main
thread stuck on a `wait-condition-variable'.
* module/ice-9/threads.scm (par-mapper): Add a `cons' argument; update
callers accordingly. Rewrite using nested futures.
* module/ice-9/threads.scm (parallel, par-mapper): Rewrite in terms of
`future' and `touch'.
* test-suite/tests/threads.test ("par-map", "par-for-each"): New test
prefixes.
* doc/ref/api-scheduling.texi (Parallel Forms): Add cross-ref to
futures. Recommend against the `n-' variants.
* module/ice-9/threads.scm: Move syntax definitions before the procedures
that use them, and rewrite as hygienic macros since they are so much
nicer that way. Fixes the thread tests.
Moved ice-9/ and oop/ under module/, with the idea being that we have
only scheme under module/. Adjusted configure.in and Makefile.am
appropriately. Put oop/ at the end of the compilation order.