*** empty log message ***
[bpt/guile.git] / libguile / coop-threads.h
CommitLineData
7bfd3b9e
JB
1/* classes: h_files */
2
0527e687
DH
3#ifndef SCM_COOP_THREADS_H
4#define SCM_COOP_THREADS_H
7bfd3b9e 5
3d7f708f 6/* Copyright (C) 1996,1997,1998,2000, 2002 Free Software Foundation, Inc.
0527e687 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.
0527e687 12 *
73be1d9e 13 * This library is distributed in the hope that it will be useful,
7bfd3b9e 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.
0527e687 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 */
0527e687 22
7bfd3b9e
JB
23\f
24
25/* This file is only included by coop-threads.c while coop-defs.h is
26 included by threads.h, which, in turn, is included by
27 libguile.h. */
28
29/* The coop_t struct is declared in coop-defs.h. */
30
31#include "libguile/__scm.h"
32
33#include <time.h>
34
a0599745
MD
35#include "libguile/coop-defs.h"
36#include "qt/qt.h"
7bfd3b9e
JB
37
38/* This code is based on a sample thread libraru by David Keppel.
39 Portions of this file fall under the following copyright: */
40
41/*
42 * QuickThreads -- Threads-building toolkit.
43 * Copyright (c) 1993 by David Keppel
44 *
45 * Permission to use, copy, modify and distribute this software and
46 * its documentation for any purpose and without fee is hereby
47 * granted, provided that the above copyright notice and this notice
48 * appear in all copies. This software is provided as a
49 * proof-of-concept and for demonstration purposes; there is no
50 * representation about the suitability of this software for any
51 * purpose.
52 */
53
7bfd3b9e
JB
54/* Each thread starts by calling a user-supplied function of this
55 type. */
56
57typedef void (coop_userf_t)(void *p0);
58
59/* Call this before any other primitives. */
33b001fd 60SCM_API void coop_init (void);
7bfd3b9e
JB
61
62/* When one or more threads are created by the main thread,
63 the system goes multithread when this is called. It is done
64 (no more runable threads) when this returns. */
65
33b001fd 66SCM_API void coop_start (void);
7bfd3b9e
JB
67
68/* Create a thread and make it runable. When the thread starts
69 running it will call `f' with arguments `p0' and `p1'. */
70
33b001fd 71SCM_API coop_t *coop_create (coop_userf_t *f, void *p0);
7bfd3b9e
JB
72
73/* The current thread stops running but stays runable.
74 It is an error to call `coop_yield' before `coop_start'
75 is called or after `coop_start' returns. */
76
33b001fd 77SCM_API void coop_yield (void);
7bfd3b9e
JB
78
79/* Like `coop_yield' but the thread is discarded. Any intermediate
80 state is lost. The thread can also terminate by simply
81 returning. */
82
33b001fd 83SCM_API void coop_abort (void);
7bfd3b9e 84
44e8413c
MD
85/* The following are needed in iselect.c */
86
33b001fd
MV
87SCM_API coop_t *coop_qget (coop_q_t *);
88SCM_API void coop_qput (coop_q_t *, coop_t *);
89SCM_API void *coop_sleephelp (qt_t *, void *, void *);
44e8413c 90
33b001fd 91SCM_API coop_t *coop_wait_for_runnable_thread ();
44e8413c 92
33b001fd
MV
93SCM_API coop_q_t coop_global_runq; /* A queue of runable threads. */
94SCM_API coop_q_t coop_global_sleepq;
95SCM_API coop_q_t coop_tmp_queue;
96SCM_API coop_q_t coop_global_allq; /* A queue of all threads. */
3d7f708f 97SCM_API coop_t *coop_global_curr; /* Currently-executing thread. */
7bfd3b9e 98
0527e687 99#endif /* SCM_COOP_THREADS_H */
89e00824
ML
100
101/*
102 Local Variables:
103 c-file-style: "gnu"
104 End:
105*/