~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to libguile/fluids.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2006-11-09 03:11:16 UTC
  • Revision ID: james.westby@ubuntu.com-20061109031116-hu0q1jxqg12y6yeg
Tags: upstream-1.8.1+1
ImportĀ upstreamĀ versionĀ 1.8.1+1

Show diffs side-by-side

added added

removed removed

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