Commit | Line | Data |
---|---|---|
44986d67 MD |
1 | #ifndef STP_H |
2 | #define STP_H | |
3 | ||
4 | /* | |
5 | * QuickThreads -- Threads-building toolkit. | |
6 | * Copyright (c) 1993 by David Keppel | |
7 | * | |
8 | * Permission to use, copy, modify and distribute this software and | |
9 | * its documentation for any purpose and without fee is hereby | |
10 | * granted, provided that the above copyright notice and this notice | |
11 | * appear in all copies. This software is provided as a | |
12 | * proof-of-concept and for demonstration purposes; there is no | |
13 | * representation about the suitability of this software for any | |
14 | * purpose. | |
15 | */ | |
16 | ||
17 | typedef struct stp_t stp_t; | |
18 | ||
19 | /* Each thread starts by calling a user-supplied function of this | |
20 | type. */ | |
21 | ||
22 | typedef void (stp_userf_t)(void *p0); | |
23 | ||
24 | /* Call this before any other primitives. */ | |
25 | extern void stp_init(); | |
26 | ||
27 | /* When one or more threads are created by the main thread, | |
28 | the system goes multithread when this is called. It is done | |
29 | (no more runable threads) when this returns. */ | |
30 | ||
31 | extern void stp_start (void); | |
32 | ||
33 | /* Create a thread and make it runable. When the thread starts | |
4a1c172e | 34 | running it will call `f' with the argument `p0'. */ |
44986d67 MD |
35 | |
36 | extern void stp_create (stp_userf_t *f, void *p0); | |
37 | ||
38 | /* The current thread stops running but stays runable. | |
39 | It is an error to call `stp_yield' before `stp_start' | |
40 | is called or after `stp_start' returns. */ | |
41 | ||
42 | extern void stp_yield (void); | |
43 | ||
44 | /* Like `stp_yield' but the thread is discarded. Any intermediate | |
45 | state is lost. The thread can also terminate by simply | |
46 | returning. */ | |
47 | ||
48 | extern void stp_abort (void); | |
49 | ||
50 | ||
51 | #endif /* ndef STP_H */ |