2006-02-01 Ludovic Courtès <ludovic.courtes@laas.fr>
[bpt/guile.git] / libguile / futures.h
CommitLineData
6b468ba4
MD
1/* classes: h_files */
2
3#ifndef SCM_FUTURES_H
4#define SCM_FUTURES_H
5
6/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
7 *
73be1d9e
MV
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.
6b468ba4 12 *
73be1d9e 13 * This library is distributed in the hope that it will be useful,
6b468ba4 14 * but 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.
6b468ba4 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
92205699 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
73be1d9e 21 */
6b468ba4
MD
22
23\f
24
2f263a6a
MV
25#if 0
26
27/* Futures have the following known bugs, which should be fixed before
28 including them in Guile:
29
30 - The implementation of the thread cache needs to be better so that
31 it behaves reasonable under heavy use.
32
33 - The dynamic state of a thread needs to be properly initialized
34 when it is retrieved from the cache.
35*/
36
6b468ba4
MD
37#include "libguile/__scm.h"
38#include "libguile/threads.h"
39
40\f
41
42typedef struct scm_t_future {
43 SCM data;
9de87eea
MV
44 scm_i_pthread_mutex_t mutex;
45 scm_i_pthread_cond_t cond;
6b468ba4
MD
46 int status;
47 int die_p;
48} scm_t_future;
49
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
54
55#define SCM_VALIDATE_FUTURE(pos, obj) \
56 SCM_ASSERT_TYPE (SCM_TYP16_PREDICATE (scm_tc16_future, obj), \
57 obj, pos, FUNC_NAME, "future");
f5710d53 58#define SCM_FUTURE(future) ((scm_t_future *) SCM_SMOB_DATA_2 (future))
6b468ba4
MD
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)
f5710d53
MV
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
6b468ba4
MD
71
72SCM_API scm_t_bits scm_tc16_future;
73
74extern SCM *scm_loc_sys_thread_handler;
75
76SCM_API SCM scm_i_make_future (SCM thunk);
77SCM_API SCM scm_make_future (SCM thunk);
78SCM_API SCM scm_future_ref (SCM future);
79
80void scm_init_futures (void);
81
2f263a6a
MV
82#endif /* Futures are disabled for now. */
83
6b468ba4
MD
84#endif /* SCM_FUTURES_H */
85
86/*
87 Local Variables:
88 c-file-style: "gnu"
89 End:
90*/