fcd5479ce384b7527111e2f58d077801f5bf2714
[debian/amanda] / xfer-src / element-glue.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 2008 Zmanda Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19
20 #ifndef ELEMENT_GLUE_H
21 #define ELEMENT_GLUE_H
22
23 #include <glib.h>
24 #include <glib-object.h>
25 #include "xfer-element.h"
26 #include "semaphore.h"
27
28 /*
29  * Class declaration
30  */
31
32 GType xfer_element_glue_get_type(void);
33 #define XFER_ELEMENT_GLUE_TYPE (xfer_element_glue_get_type())
34 #define XFER_ELEMENT_GLUE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_element_glue_get_type(), XferElementGlue)
35 #define XFER_ELEMENT_GLUE_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_element_glue_get_type(), XferElementGlue const)
36 #define XFER_ELEMENT_GLUE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), xfer_element_glue_get_type(), XferElementGlueClass)
37 #define IS_XFER_ELEMENT_GLUE(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), xfer_element_glue_get_type ())
38 #define XFER_ELEMENT_GLUE_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), xfer_element_glue_get_type(), XferElementGlueClass)
39
40 /*
41  * Main object structure
42  */
43
44 typedef struct XferElementGlue {
45     XferElement __parent__;
46
47     /* the stuff we might use, depending on what flavor of glue we're
48      * providing.. */
49     int pipe[2];
50
51     /* for push/pull, a ring buffer of ptr/size pairs */
52     struct { gpointer buf; size_t size; } *ring;
53     semaphore_t *ring_used_sem, *ring_free_sem;
54     gint ring_head, ring_tail;
55
56     GThread *thread;
57     GThreadFunc threadfunc;
58 } XferElementGlue;
59
60 /*
61  * Class definition
62  */
63
64 typedef struct {
65     XferElementClass __parent__;
66 } XferElementGlueClass;
67
68 /* Constructor */
69
70 XferElement * xfer_element_glue(void);
71
72 /* the mech pairs supported by this object */
73
74 extern xfer_element_mech_pair_t *xfer_element_glue_mech_pairs;
75
76 #endif