1 | /* GStreamer |
---|
2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * 2000 Wim Taymans <wtay@chello.be> |
---|
4 | * |
---|
5 | * cothreads.h: Header for cothreading routines |
---|
6 | * |
---|
7 | * This library is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU Library General Public |
---|
9 | * License as published by the Free Software Foundation; either |
---|
10 | * version 2 of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | * Library General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU Library General Public |
---|
18 | * License along with this library; if not, write to the |
---|
19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
20 | * Boston, MA 02111-1307, USA. |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef __COTHREADS_H__ |
---|
24 | #define __COTHREADS_H__ |
---|
25 | |
---|
26 | #include <glib.h> |
---|
27 | #include <setjmp.h> |
---|
28 | |
---|
29 | typedef struct _cothread_state cothread_state; |
---|
30 | typedef struct _cothread_context cothread_context; |
---|
31 | |
---|
32 | typedef int (*cothread_func) (int argc,char **argv); |
---|
33 | |
---|
34 | #define COTHREAD_STARTED 0x01 |
---|
35 | #define COTHREAD_DESTROYED 0x02 |
---|
36 | |
---|
37 | struct _cothread_state { |
---|
38 | cothread_context *ctx; |
---|
39 | int cothreadnum; |
---|
40 | gpointer priv; |
---|
41 | |
---|
42 | cothread_func func; |
---|
43 | int argc; |
---|
44 | char **argv; |
---|
45 | |
---|
46 | int flags; |
---|
47 | void *sp; |
---|
48 | jmp_buf jmp; |
---|
49 | void *stack_base; |
---|
50 | unsigned long stack_size; |
---|
51 | |
---|
52 | int magic_number; |
---|
53 | }; |
---|
54 | |
---|
55 | |
---|
56 | cothread_context* cothread_context_init (void); |
---|
57 | void cothread_context_free (cothread_context *ctx); |
---|
58 | void cothread_context_set_data (cothread_state *cothread, |
---|
59 | gchar *key, gpointer data); |
---|
60 | gpointer cothread_context_get_data (cothread_state *cothread, gchar *key); |
---|
61 | |
---|
62 | cothread_state* cothread_create (cothread_context *ctx); |
---|
63 | void cothread_free (cothread_state *cothread); |
---|
64 | void cothread_setfunc (cothread_state *cothread, cothread_func func, |
---|
65 | int argc, char **argv); |
---|
66 | void cothread_stop (cothread_state *cothread); |
---|
67 | |
---|
68 | void cothread_switch (cothread_state *cothread); |
---|
69 | void cothread_set_private (cothread_state *cothread, |
---|
70 | gpointer data); |
---|
71 | gpointer cothread_get_private (cothread_state *cothread); |
---|
72 | |
---|
73 | cothread_state* cothread_main (cothread_context *ctx); |
---|
74 | cothread_state* cothread_current_main (void); |
---|
75 | cothread_state* cothread_current (void); |
---|
76 | |
---|
77 | #endif /* __COTHREAD_H__ */ |
---|