Merge branch 'master' into boehm-demers-weiser-gc
[bpt/guile.git] / libguile / fluids.h
CommitLineData
9482a297
MV
1/* classes: h_files */
2
dee01b01
DH
3#ifndef SCM_FLUIDS_H
4#define SCM_FLUIDS_H
9482a297 5
102dbb6f 6/* Copyright (C) 1996,2000,2001, 2006, 2008 Free Software Foundation, Inc.
dee01b01 7 *
73be1d9e 8 * This library is free software; you can redistribute it and/or
53befeb7
NJ
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
dee01b01 12 *
53befeb7
NJ
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
73be1d9e
MV
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
dee01b01 17 *
73be1d9e
MV
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
53befeb7
NJ
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301 USA
73be1d9e 22 */
9482a297 23
dee01b01 24\f
d3a6bc94 25
9482a297
MV
26#include "libguile/__scm.h"
27#include "libguile/root.h"
28#include "libguile/vectors.h"
29
30/* Fluids.
31
32 Fluids are objects of a certain type (a smob) that can hold one SCM
9de87eea
MV
33 value per dynamic state. That is, modifications to this value are
34 only visible to code that executes with the same dynamic state as
35 the modifying code. When a new dynamic state is constructed, it
9482a297 36 inherits the values from its parent. Because each thread executes
9de87eea 37 with its own dynamic state, you can use fluids for thread local
9482a297
MV
38 storage.
39
40 Each fluid is identified by a small integer. This integer is used
9de87eea
MV
41 to index a vector that holds the values of all fluids. A dynamic
42 state consists of this vector, wrapped in a smob so that the vector
43 can grow.
44 */
9482a297
MV
45
46/* The fastest way to acces/modify the value of a fluid. These macros
9de87eea
MV
47 do no error checking at all. The first argument is the index
48 number of the fluid, obtained via SCM_FLUID_NUM, not the fluid
49 itself. You must make sure that the fluid remains protected as
50 long you use its number since numbers of unused fluids are reused
51 eventually.
52*/
9482a297 53
33b001fd 54SCM_API SCM scm_make_fluid (void);
9de87eea 55SCM_API int scm_is_fluid (SCM obj);
33b001fd
MV
56SCM_API SCM scm_fluid_p (SCM fl);
57SCM_API SCM scm_fluid_ref (SCM fluid);
58SCM_API SCM scm_fluid_set_x (SCM fluid, SCM value);
9482a297 59
33b001fd
MV
60SCM_API SCM scm_c_with_fluids (SCM fluids, SCM vals,
61 SCM (*cproc)(void *), void *cdata);
62SCM_API SCM scm_c_with_fluid (SCM fluid, SCM val,
63 SCM (*cproc)(void *), void *cdata);
64SCM_API SCM scm_with_fluids (SCM fluids, SCM vals, SCM thunk);
bebd3fba 65SCM_API SCM scm_with_fluid (SCM fluid, SCM val, SCM thunk);
b3460a50 66
661ae7ab 67SCM_API void scm_dynwind_fluid (SCM fluid, SCM value);
ef20bf70 68
9de87eea
MV
69SCM_API SCM scm_make_dynamic_state (SCM parent);
70SCM_API SCM scm_dynamic_state_p (SCM obj);
71SCM_API int scm_is_dynamic_state (SCM obj);
72SCM_API SCM scm_current_dynamic_state (void);
73SCM_API SCM scm_set_current_dynamic_state (SCM state);
661ae7ab 74SCM_API void scm_dynwind_current_dynamic_state (SCM state);
9de87eea
MV
75SCM_API void *scm_c_with_dynamic_state (SCM state,
76 void *(*func)(void *), void *data);
77SCM_API SCM scm_with_dynamic_state (SCM state, SCM proc);
78
102dbb6f 79SCM_INTERNAL SCM scm_i_make_initial_dynamic_state (void);
9482a297 80
102dbb6f
LC
81SCM_INTERNAL void scm_fluids_prehistory (void);
82SCM_INTERNAL void scm_init_fluids (void);
9482a297 83
dee01b01 84#endif /* SCM_FLUIDS_H */
89e00824
ML
85
86/*
87 Local Variables:
88 c-file-style: "gnu"
89 End:
90*/