Changed license terms to the plain LGPL thru-out.
[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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
6b468ba4
MD
22
23\f
24
25#include "libguile/__scm.h"
26#include "libguile/threads.h"
27
28\f
29
30typedef struct scm_t_future {
31 SCM data;
32 scm_t_mutex mutex;
33 scm_t_cond cond;
34 int status;
35 int die_p;
36} scm_t_future;
37
38#define SCM_FUTURE_DEAD 0
39#define SCM_FUTURE_SIGNAL_ME -1
40#define SCM_FUTURE_COMPUTING 1
41#define SCM_FUTURE_TASK_ASSIGNED 2
42
43#define SCM_VALIDATE_FUTURE(pos, obj) \
44 SCM_ASSERT_TYPE (SCM_TYP16_PREDICATE (scm_tc16_future, obj), \
45 obj, pos, FUNC_NAME, "future");
46#define SCM_FUTURE(future) ((scm_t_future *) SCM_CELL_WORD_2 (future))
47#define SCM_FUTURE_MUTEX(future) (&SCM_FUTURE (future)->mutex)
48#define SCM_FUTURE_COND(future) (&SCM_FUTURE (future)->cond)
49#define SCM_FUTURE_STATUS(future) (SCM_FUTURE (future)->status)
50#define SCM_SET_FUTURE_STATUS(future, x) \
51 do { SCM_FUTURE (future)->status = (x); } while (0)
52#define SCM_FUTURE_ALIVE_P(future) (SCM_FUTURE_STATUS (future))
53#define SCM_FUTURE_DATA(future) (SCM_FUTURE (future)->data)
54#define SCM_SET_FUTURE_DATA(future, x) \
55 do { SCM_FUTURE (future)->data = (x); } while (0)
56#define SCM_FUTURE_NEXT SCM_CELL_OBJECT_1
57#define SCM_FUTURE_NEXTLOC(x) ((SCM *) SCM_CELL_WORD_LOC ((x), 1))
58#define SCM_SET_FUTURE_NEXT SCM_SET_CELL_OBJECT_1
59
60SCM_API scm_t_bits scm_tc16_future;
61
62extern SCM *scm_loc_sys_thread_handler;
63
64SCM_API SCM scm_i_make_future (SCM thunk);
65SCM_API SCM scm_make_future (SCM thunk);
66SCM_API SCM scm_future_ref (SCM future);
67
68void scm_init_futures (void);
69
70#endif /* SCM_FUTURES_H */
71
72/*
73 Local Variables:
74 c-file-style: "gnu"
75 End:
76*/