Revert "GIOScheduler: Avoid constant iteration over pending job list"
[platform/upstream/glib.git] / gio / giostream.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright © 2008, 2009 Codethink Limited
4  * Copyright © 2009 Red Hat, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 2 of the licence or (at
9  * your option) any later version.
10  *
11  * See the included COPYING file for more information.
12  *
13  * Authors: Ryan Lortie <desrt@desrt.ca>
14  *          Alexander Larsson <alexl@redhat.com>
15  */
16
17 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
18 #error "Only <gio/gio.h> can be included directly."
19 #endif
20
21 #ifndef __G_IO_STREAM_H__
22 #define __G_IO_STREAM_H__
23
24 #include <gio/ginputstream.h>
25 #include <gio/goutputstream.h>
26 #include <gio/gcancellable.h>
27 #include <gio/gioerror.h>
28
29 G_BEGIN_DECLS
30
31 #define G_TYPE_IO_STREAM         (g_io_stream_get_type ())
32 #define G_IO_STREAM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_IO_STREAM, GIOStream))
33 #define G_IO_STREAM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_IO_STREAM, GIOStreamClass))
34 #define G_IS_IO_STREAM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_IO_STREAM))
35 #define G_IS_IO_STREAM_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_IO_STREAM))
36 #define G_IO_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_IO_STREAM, GIOStreamClass))
37
38 typedef struct _GIOStreamPrivate                            GIOStreamPrivate;
39 typedef struct _GIOStreamClass                              GIOStreamClass;
40
41 /**
42  * GIOStream:
43  *
44  * Base class for read-write streams.
45  **/
46 struct _GIOStream
47 {
48   GObject parent_instance;
49
50   /*< private >*/
51   GIOStreamPrivate *priv;
52 };
53
54 struct _GIOStreamClass
55 {
56   GObjectClass parent_class;
57
58   GInputStream *  (*get_input_stream)  (GIOStream *stream);
59   GOutputStream * (*get_output_stream) (GIOStream *stream);
60
61   gboolean (* close_fn)     (GIOStream           *stream,
62                              GCancellable        *cancellable,
63                              GError             **error);
64   void     (* close_async)  (GIOStream           *stream,
65                              int                  io_priority,
66                              GCancellable        *cancellable,
67                              GAsyncReadyCallback  callback,
68                              gpointer             user_data);
69   gboolean (* close_finish) (GIOStream           *stream,
70                              GAsyncResult        *result,
71                              GError             **error);
72   /*< private >*/
73   /* Padding for future expansion */
74   void (*_g_reserved1) (void);
75   void (*_g_reserved2) (void);
76   void (*_g_reserved3) (void);
77   void (*_g_reserved4) (void);
78   void (*_g_reserved5) (void);
79   void (*_g_reserved6) (void);
80   void (*_g_reserved7) (void);
81   void (*_g_reserved8) (void);
82   void (*_g_reserved9) (void);
83   void (*_g_reserved10) (void);
84 };
85
86 GType          g_io_stream_get_type          (void)  G_GNUC_CONST;
87
88 GInputStream * g_io_stream_get_input_stream  (GIOStream            *stream);
89 GOutputStream *g_io_stream_get_output_stream (GIOStream            *stream);
90
91 void           g_io_stream_splice_async      (GIOStream            *stream1,
92                                               GIOStream            *stream2,
93                                               GIOStreamSpliceFlags  flags,
94                                               int                   io_priority,
95                                               GCancellable         *cancellable,
96                                               GAsyncReadyCallback   callback,
97                                               gpointer              user_data);
98
99 gboolean       g_io_stream_splice_finish     (GAsyncResult         *result,
100                                               GError              **error);
101
102 gboolean       g_io_stream_close             (GIOStream            *stream,
103                                               GCancellable         *cancellable,
104                                               GError              **error);
105
106 void           g_io_stream_close_async       (GIOStream            *stream,
107                                               int                   io_priority,
108                                               GCancellable         *cancellable,
109                                               GAsyncReadyCallback   callback,
110                                               gpointer              user_data);
111 gboolean       g_io_stream_close_finish      (GIOStream            *stream,
112                                               GAsyncResult         *result,
113                                               GError              **error);
114
115 gboolean       g_io_stream_is_closed         (GIOStream            *stream);
116 gboolean       g_io_stream_has_pending       (GIOStream            *stream);
117 gboolean       g_io_stream_set_pending       (GIOStream            *stream,
118                                               GError              **error);
119 void           g_io_stream_clear_pending     (GIOStream            *stream);
120
121 G_END_DECLS
122
123 #endif /* __G_IO_STREAM_H__ */