6 /* Copyright (C) 2002, 2003, 2006, 2008 Free Software Foundation, Inc.
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.
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.
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
27 /* Futures have the following known bugs, which should be fixed before
28 including them in Guile:
30 - The implementation of the thread cache needs to be better so that
31 it behaves reasonable under heavy use.
33 - The dynamic state of a thread needs to be properly initialized
34 when it is retrieved from the cache.
37 #include "libguile/__scm.h"
38 #include "libguile/threads.h"
42 typedef struct scm_t_future
{
44 scm_i_pthread_mutex_t mutex
;
45 scm_i_pthread_cond_t cond
;
50 #define SCM_FUTURE_DEAD 0
51 #define SCM_FUTURE_SIGNAL_ME -1
52 #define SCM_FUTURE_COMPUTING 1
53 #define SCM_FUTURE_TASK_ASSIGNED 2
55 #define SCM_VALIDATE_FUTURE(pos, obj) \
56 SCM_ASSERT_TYPE (SCM_TYP16_PREDICATE (scm_tc16_future, obj), \
57 obj, pos, FUNC_NAME, "future");
58 #define SCM_FUTURE(future) ((scm_t_future *) SCM_SMOB_DATA_2 (future))
59 #define SCM_FUTURE_MUTEX(future) (&SCM_FUTURE (future)->mutex)
60 #define SCM_FUTURE_COND(future) (&SCM_FUTURE (future)->cond)
61 #define SCM_FUTURE_STATUS(future) (SCM_FUTURE (future)->status)
62 #define SCM_SET_FUTURE_STATUS(future, x) \
63 do { SCM_FUTURE (future)->status = (x); } while (0)
64 #define SCM_FUTURE_ALIVE_P(future) (SCM_FUTURE_STATUS (future))
65 #define SCM_FUTURE_DATA(future) (SCM_FUTURE (future)->data)
66 #define SCM_SET_FUTURE_DATA(future, x) \
67 do { SCM_FUTURE (future)->data = (x); } while (0)
68 #define SCM_FUTURE_NEXT SCM_SMOB_OBJECT
69 #define SCM_FUTURE_NEXTLOC SCM_SMOB_OBJECT_LOC
70 #define SCM_SET_FUTURE_NEXT SCM_SET_SMOB_OBJECT
72 SCM_API scm_t_bits scm_tc16_future
;
74 extern SCM
*scm_loc_sys_thread_handler
;
76 SCM_INTERNAL SCM
scm_i_make_future (SCM thunk
);
77 SCM_API SCM
scm_make_future (SCM thunk
);
78 SCM_API SCM
scm_future_ref (SCM future
);
80 void scm_init_futures (void);
82 #endif /* Futures are disabled for now. */
84 #endif /* SCM_FUTURES_H */