Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:58

0001 /* GIO - GLib Input, Output and Streaming Library
0002  *
0003  * Copyright (C) 2010 Red Hat, Inc.
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-or-later
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Lesser General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2.1 of the License, or (at your option) any later version.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General
0018  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
0019  */
0020 
0021 #ifndef __G_POLLABLE_OUTPUT_STREAM_H__
0022 #define __G_POLLABLE_OUTPUT_STREAM_H__
0023 
0024 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
0025 #error "Only <gio/gio.h> can be included directly."
0026 #endif
0027 
0028 #include <gio/gio.h>
0029 
0030 G_BEGIN_DECLS
0031 
0032 #define G_TYPE_POLLABLE_OUTPUT_STREAM               (g_pollable_output_stream_get_type ())
0033 #define G_POLLABLE_OUTPUT_STREAM(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_POLLABLE_OUTPUT_STREAM, GPollableOutputStream))
0034 #define G_IS_POLLABLE_OUTPUT_STREAM(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_POLLABLE_OUTPUT_STREAM))
0035 #define G_POLLABLE_OUTPUT_STREAM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_POLLABLE_OUTPUT_STREAM, GPollableOutputStreamInterface))
0036 
0037 typedef struct _GPollableOutputStreamInterface GPollableOutputStreamInterface;
0038 
0039 /**
0040  * GPollableOutputStreamInterface:
0041  * @g_iface: The parent interface.
0042  * @can_poll: Checks if the #GPollableOutputStream instance is actually pollable
0043  * @is_writable: Checks if the stream is writable
0044  * @create_source: Creates a #GSource to poll the stream
0045  * @write_nonblocking: Does a non-blocking write or returns
0046  *   %G_IO_ERROR_WOULD_BLOCK
0047  * @writev_nonblocking: Does a vectored non-blocking write, or returns
0048  *   %G_POLLABLE_RETURN_WOULD_BLOCK
0049  *
0050  * The interface for pollable output streams.
0051  *
0052  * The default implementation of @can_poll always returns %TRUE.
0053  *
0054  * The default implementation of @write_nonblocking calls
0055  * g_pollable_output_stream_is_writable(), and then calls
0056  * g_output_stream_write() if it returns %TRUE. This means you only
0057  * need to override it if it is possible that your @is_writable
0058  * implementation may return %TRUE when the stream is not actually
0059  * writable.
0060  *
0061  * The default implementation of @writev_nonblocking calls
0062  * g_pollable_output_stream_write_nonblocking() for each vector, and converts
0063  * its return value and error (if set) to a #GPollableReturn. You should
0064  * override this where possible to avoid having to allocate a #GError to return
0065  * %G_IO_ERROR_WOULD_BLOCK.
0066  *
0067  * Since: 2.28
0068  */
0069 struct _GPollableOutputStreamInterface
0070 {
0071   GTypeInterface g_iface;
0072 
0073   /* Virtual Table */
0074   gboolean     (*can_poll)          (GPollableOutputStream  *stream);
0075 
0076   gboolean     (*is_writable)       (GPollableOutputStream  *stream);
0077   GSource *    (*create_source)     (GPollableOutputStream  *stream,
0078                      GCancellable           *cancellable);
0079   gssize       (*write_nonblocking) (GPollableOutputStream  *stream,
0080                      const void             *buffer,
0081                      gsize                   count,
0082                      GError                **error);
0083   GPollableReturn (*writev_nonblocking) (GPollableOutputStream  *stream,
0084                      const GOutputVector    *vectors,
0085                      gsize                   n_vectors,
0086                      gsize                  *bytes_written,
0087                      GError                **error);
0088 };
0089 
0090 GIO_AVAILABLE_IN_ALL
0091 GType    g_pollable_output_stream_get_type          (void) G_GNUC_CONST;
0092 
0093 GIO_AVAILABLE_IN_ALL
0094 gboolean g_pollable_output_stream_can_poll          (GPollableOutputStream  *stream);
0095 
0096 GIO_AVAILABLE_IN_ALL
0097 gboolean g_pollable_output_stream_is_writable       (GPollableOutputStream  *stream);
0098 GIO_AVAILABLE_IN_ALL
0099 GSource *g_pollable_output_stream_create_source     (GPollableOutputStream  *stream,
0100                              GCancellable           *cancellable);
0101 
0102 GIO_AVAILABLE_IN_ALL
0103 gssize   g_pollable_output_stream_write_nonblocking (GPollableOutputStream  *stream,
0104                              const void             *buffer,
0105                              gsize                   count,
0106                              GCancellable           *cancellable,
0107                              GError                **error);
0108 
0109 GIO_AVAILABLE_IN_2_60
0110 GPollableReturn g_pollable_output_stream_writev_nonblocking (GPollableOutputStream  *stream,
0111                                  const GOutputVector    *vectors,
0112                                  gsize                   n_vectors,
0113                                  gsize                  *bytes_written,
0114                                  GCancellable           *cancellable,
0115                                  GError                **error);
0116 
0117 G_END_DECLS
0118 
0119 
0120 #endif /* __G_POLLABLE_OUTPUT_STREAM_H__ */