2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * cothreads.h: Header for cothreading routines
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.
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.
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.
23 #ifndef __COTHREADS_H__
24 #define __COTHREADS_H__
29 typedef struct _cothread_state cothread_state;
30 typedef struct _cothread_context cothread_context;
32 typedef int (*cothread_func) (int argc,char **argv);
34 #define COTHREAD_STARTED 0x01
35 #define COTHREAD_DESTROYED 0x02
37 struct _cothread_state {
38 cothread_context *ctx;
50 unsigned long stack_size;
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);
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);
68 void cothread_switch (cothread_state *cothread);
69 void cothread_set_private (cothread_state *cothread,
71 gpointer cothread_get_private (cothread_state *cothread);
73 void cothread_lock (cothread_state *cothread);
74 gboolean cothread_trylock (cothread_state *cothread);
75 void cothread_unlock (cothread_state *cothread);
77 cothread_state* cothread_main (cothread_context *ctx);
78 cothread_state* cothread_current_main (void);
79 cothread_state* cothread_current (void);
81 #endif /* __COTHREAD_H__ */