1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-04 08:40:21 +02:00

Inline thread wakeup data into "struct scm_thread"

This way we don't allocate an untagged wake data, and we don't need a
type tag.  On the other hand we have to roll a more complicated seqlock,
but that's fine.

Also switch to require C11 atomics.

* libguile/atomics-internal.h: Remove fallback for when we don't have
C11 atomics.
(scm_atomic_ref_uint32, scm_atomic_swap_uint32, scm_atomic_set_uint32):
New helpers.
* libguile/threads-internal.h:
* libguile/async.h:
* libguile/async.c: Inline the thread wake data.  Happily, waking a
remote thread is still wait-free from both sides.
This commit is contained in:
Andy Wingo 2025-06-25 16:00:07 +02:00
parent 7d1eda149e
commit b0ce014801
4 changed files with 170 additions and 179 deletions

View file

@ -29,6 +29,16 @@
struct gc_mutator;
/* See async.c for the details about how to wake up a thread. */
struct scm_thread_wake_data
{
uint32_t seq;
int state;
int fd;
scm_i_pthread_mutex_t *mutex;
scm_i_pthread_cond_t *cond;
};
struct scm_thread {
scm_t_bits tag;
@ -58,7 +68,7 @@ struct scm_thread {
this thread exits. */
int needs_unregister;
struct scm_thread_wake_data *wake;
struct scm_thread_wake_data wake_data;
scm_i_pthread_cond_t sleep_cond;
int sleep_pipe[2];