- Removed unused locking from the cothreads
[platform/upstream/gstreamer.git] / gst / gstthread.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstthread.h: Header for GstThread object
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
24 #ifndef __GST_THREAD_H__
25 #define __GST_THREAD_H__
26
27 #include <unistd.h>
28 #include <pthread.h>
29
30 #include <gst/gstbin.h>
31
32
33 G_BEGIN_DECLS
34
35 extern GstElementDetails gst_thread_details;
36
37
38 typedef enum {
39   GST_THREAD_STATE_STARTED      = GST_BIN_FLAG_LAST,
40   GST_THREAD_STATE_SPINNING,
41   GST_THREAD_STATE_REAPING,
42
43   /* padding */
44   GST_THREAD_FLAG_LAST          = GST_BIN_FLAG_LAST + 4,
45 } GstThreadState;
46
47
48 #define GST_TYPE_THREAD \
49   (gst_thread_get_type())
50 #define GST_THREAD(obj) \
51   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_THREAD,GstThread))
52 #define GST_THREAD_CLASS(klass) \
53   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_THREAD,GstThreadClass))
54 #define GST_IS_THREAD(obj) \
55   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_THREAD))
56 #define GST_IS_THREAD_CLASS(obj) \
57   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_THREAD))
58
59 typedef struct _GstThread       GstThread;
60 typedef struct _GstThreadClass  GstThreadClass;
61
62 struct _GstThread {
63   GstBin         bin;
64
65   pthread_t      thread_id;             /* id of the thread, if any */
66   pthread_attr_t attr;                  /* attributes for the stack space */
67   int            sched_policy;
68   int            priority;
69   void          *stack;                 /* set with gst_scheduler_get_preferred_stack */
70   gint           pid;                   /* the pid of the thread */
71   gint           ppid;                  /* the pid of the thread's parent process */
72   GMutex        *lock;                  /* thread lock/condititon pair ... */
73   GCond         *cond;                  /* .... used to control the thread */
74
75   gint           transition;            /* the current state transition */
76 };
77
78 struct _GstThreadClass {
79   GstBinClass parent_class;
80
81   /* signals */
82   void  (*shutdown)     (GstThread *thread);
83 };
84
85 GType   gst_thread_get_type     (void);
86
87 GstElement*     gst_thread_new          (const gchar *name);
88
89 G_END_DECLS
90
91
92 #endif /* __GST_THREAD_H__ */     
93