summaryrefslogtreecommitdiff
path: root/libguile/fluids.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-03-07 20:57:59 +0100
committerAndy Wingo <wingo@pobox.com>2017-03-07 21:15:39 +0100
commitfb8c91a35c0a1c357aab96a6721a8b65c93368b0 (patch)
tree2071a8a79753305d413ce2c70c084902e9cd7044 /libguile/fluids.h
parent84a740d86a5afd235f1b47ac66c88db010b1d56b (diff)
downloadguile-fb8c91a35c0a1c357aab96a6721a8b65c93368b0.tar.gz
Add thread local fluids
* libguile/fluids.h (struct scm_dynamic_state): Add thread_local_values table. Thread locals are flushed to a separate thread-local table. The references are strong references since the table never escapes the thread. (scm_make_thread_local_fluid, scm_fluid_thread_local_p): New functions. * libguile/fluids.c (FLUID_F_THREAD_LOCAL): (SCM_I_FLUID_THREAD_LOCAL_P): New macros. (restore_dynamic_state): Add comment about precondition. (save_dynamic_state): Flush thread locals. (scm_i_fluid_print): Print thread locals nicely. (new_fluid): Add flags arg. (scm_make_fluid, scm_make_fluid_with_default, scm_make_unbound_fluid): Adapt. (scm_make_thread_local_fluid, scm_fluid_thread_local_p): New functions. (fluid_set_x): Special flushing logic for thread-locals. (fluid_ref): Special cache miss logic for thread locals. * libguile/stacks.c (scm_init_stacks): * libguile/throw.c (scm_init_throw): %stacks and %exception-handler are thread-locals. * libguile/threads.c (guilify_self_2): Init thread locals table. * test-suite/tests/fluids.test ("dynamic states"): Add test. * doc/ref/api-control.texi (Fluids and Dynamic States): Add link to Thread-Local Variables. * doc/ref/api-scheduling.texi (Thread Local Variables): Update with real thread-locals. * NEWS: Update.
Diffstat (limited to 'libguile/fluids.h')
-rw-r--r--libguile/fluids.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libguile/fluids.h b/libguile/fluids.h
index 6d7969e15..7997ad4d3 100644
--- a/libguile/fluids.h
+++ b/libguile/fluids.h
@@ -44,6 +44,7 @@
struct scm_dynamic_state
{
+ SCM thread_local_values;
SCM values;
uint8_t has_aliased_values;
struct scm_cache cache;
@@ -53,8 +54,10 @@ struct scm_dynamic_state
SCM_API SCM scm_make_fluid (void);
SCM_API SCM scm_make_fluid_with_default (SCM dflt);
SCM_API SCM scm_make_unbound_fluid (void);
+SCM_API SCM scm_make_thread_local_fluid (SCM dflt);
SCM_API int scm_is_fluid (SCM obj);
SCM_API SCM scm_fluid_p (SCM fl);
+SCM_API SCM scm_fluid_thread_local_p (SCM fluid);
SCM_API SCM scm_fluid_ref (SCM fluid);
SCM_API SCM scm_fluid_ref_star (SCM fluid, SCM depth);
SCM_API SCM scm_fluid_set_x (SCM fluid, SCM value);