Blame docs/reference/gio/html/GPollableInputStream.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>GPollableInputStream: GIO Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GIO Reference Manual">
Packit ae235b
<link rel="up" href="streaming.html" title="Streaming I/O">
Packit ae235b
<link rel="prev" href="gio-GConverterOutputstream.html" title="GConverterOutputstream">
Packit ae235b
<link rel="next" href="GPollableOutputStream.html" title="GPollableOutputStream">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description  | 
Packit ae235b
                  Object Hierarchy  | 
Packit ae235b
                  Prerequisites  | 
Packit ae235b
                  Known Implementations
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

GPollableInputStream

Packit ae235b

GPollableInputStream — Interface for pollable input streams

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_pollable_input_stream_can_poll ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_pollable_input_stream_is_readable ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GSource *
Packit ae235b
Packit ae235b
Packit ae235b
g_pollable_input_stream_create_source ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gssize
Packit ae235b
Packit ae235b
Packit ae235b
g_pollable_input_stream_read_nonblocking ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
 
Packit ae235b
GPollableInputStream
Packit ae235b
Packit ae235b
Packit ae235b
struct
Packit ae235b
GPollableInputStreamInterface
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Object Hierarchy

Packit ae235b
    GInterface
Packit ae235b
    ╰── GPollableInputStream
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Prerequisites

Packit ae235b

Packit ae235b
GPollableInputStream requires
Packit ae235b
 GInputStream.

Packit ae235b
Packit ae235b
Packit ae235b

Known Implementations

Packit ae235b

Packit ae235b
GPollableInputStream is implemented by
Packit ae235b
 GConverterInputStream,  GMemoryInputStream and  GUnixInputStream.

Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <gio/gio.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

GPollableInputStream is implemented by GInputStreams that

Packit ae235b
can be polled for readiness to read. This can be used when
Packit ae235b
interfacing with a non-GIO API that expects
Packit ae235b
UNIX-file-descriptor-style asynchronous I/O rather than GIO-style.

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

g_pollable_input_stream_can_poll ()

Packit ae235b
gboolean
Packit ae235b
g_pollable_input_stream_can_poll (GPollableInputStream *stream);
Packit ae235b

Checks if stream

Packit ae235b
 is actually pollable. Some classes may implement
Packit ae235b
GPollableInputStream but have only certain instances of that class
Packit ae235b
be pollable. If this method returns FALSE, then the behavior of
Packit ae235b
other GPollableInputStream methods is undefined.

Packit ae235b

For any given stream, the value returned by this method is constant;

Packit ae235b
a stream cannot switch from pollable to non-pollable or vice versa.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GPollableInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if stream

Packit ae235b
is pollable, FALSE if not.

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_pollable_input_stream_is_readable ()

Packit ae235b
gboolean
Packit ae235b
g_pollable_input_stream_is_readable (GPollableInputStream *stream);
Packit ae235b

Checks if stream

Packit ae235b
 can be read.

Packit ae235b

Note that some stream types may not be able to implement this 100%

Packit ae235b
reliably, and it is possible that a call to g_input_stream_read()
Packit ae235b
after this returns TRUE would still block. To guarantee
Packit ae235b
non-blocking behavior, you should always use
Packit ae235b
g_pollable_input_stream_read_nonblocking(), which will return a
Packit ae235b
G_IO_ERROR_WOULD_BLOCK error rather than blocking.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GPollableInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if stream

Packit ae235b
is readable, FALSE if not. If an error
Packit ae235b
has occurred on stream
Packit ae235b
, this will result in
Packit ae235b
g_pollable_input_stream_is_readable() returning TRUE, and the
Packit ae235b
next attempt to read will return the error.

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_pollable_input_stream_create_source ()

Packit ae235b
GSource *
Packit ae235b
g_pollable_input_stream_create_source (GPollableInputStream *stream,
Packit ae235b
                                       GCancellable *cancellable);
Packit ae235b

Creates a GSource that triggers when stream

Packit ae235b
 can be read, or
Packit ae235b
cancellable
Packit ae235b
 is triggered or an error occurs. The callback on the
Packit ae235b
source is of the GPollableSourceFunc type.

Packit ae235b

As with g_pollable_input_stream_is_readable(), it is possible that

Packit ae235b
the stream may not actually be readable even after the source
Packit ae235b
triggers, so you should use g_pollable_input_stream_read_nonblocking()
Packit ae235b
rather than g_input_stream_read() from the callback.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GPollableInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

a GCancellable, or NULL.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a new GSource.

Packit ae235b

[transfer full]

Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_pollable_input_stream_read_nonblocking ()

Packit ae235b
gssize
Packit ae235b
g_pollable_input_stream_read_nonblocking
Packit ae235b
                               (GPollableInputStream *stream,
Packit ae235b
                                void *buffer,
Packit ae235b
                                gsize count,
Packit ae235b
                                GCancellable *cancellable,
Packit ae235b
                                GError **error);
Packit ae235b

Attempts to read up to count

Packit ae235b
 bytes from stream
Packit ae235b
 into buffer
Packit ae235b
, as
Packit ae235b
with g_input_stream_read(). If stream
Packit ae235b
 is not currently readable,
Packit ae235b
this will immediately return G_IO_ERROR_WOULD_BLOCK, and you can
Packit ae235b
use g_pollable_input_stream_create_source() to create a GSource
Packit ae235b
that will be triggered when stream
Packit ae235b
 is readable.

Packit ae235b

Note that since this method never blocks, you cannot actually

Packit ae235b
use cancellable
Packit ae235b
 to cancel it. However, it will return an error
Packit ae235b
if cancellable
Packit ae235b
 has already been cancelled when you call, which
Packit ae235b
may happen if you call this method after a source triggers due
Packit ae235b
to having been cancelled.

Packit ae235b

Virtual: read_nonblocking

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GPollableInputStream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

buffer

Packit ae235b

a buffer to

Packit ae235b
read data into (which should be at least count
Packit ae235b
bytes long). 

Packit ae235b
[array length=count][element-type guint8]
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes you want to read

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

a GCancellable, or NULL.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

GError for error reporting, or NULL to ignore.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the number of bytes read, or -1 on error (including

Packit ae235b
G_IO_ERROR_WOULD_BLOCK).

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

GPollableInputStream

Packit ae235b
typedef struct _GPollableInputStream GPollableInputStream;
Packit ae235b

An interface for a GInputStream that can be polled for readability.

Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

struct GPollableInputStreamInterface

Packit ae235b
struct GPollableInputStreamInterface {
Packit ae235b
  GTypeInterface g_iface;
Packit ae235b
Packit ae235b
  /* Virtual Table */
Packit ae235b
  gboolean     (*can_poll)         (GPollableInputStream  *stream);
Packit ae235b
Packit ae235b
  gboolean     (*is_readable)      (GPollableInputStream  *stream);
Packit ae235b
  GSource *    (*create_source)    (GPollableInputStream  *stream,
Packit ae235b
				    GCancellable          *cancellable);
Packit ae235b
  gssize       (*read_nonblocking) (GPollableInputStream  *stream,
Packit ae235b
				    void                  *buffer,
Packit ae235b
				    gsize                  count,
Packit ae235b
				    GError               **error);
Packit ae235b
};
Packit ae235b
Packit ae235b

The interface for pollable input streams.

Packit ae235b

The default implementation of can_poll

Packit ae235b
 always returns TRUE.

Packit ae235b

The default implementation of read_nonblocking

Packit ae235b
 calls
Packit ae235b
g_pollable_input_stream_is_readable(), and then calls
Packit ae235b
g_input_stream_read() if it returns TRUE. This means you only need
Packit ae235b
to override it if it is possible that your is_readable
Packit ae235b
Packit ae235b
implementation may return TRUE when the stream is not actually
Packit ae235b
readable.

Packit ae235b
Packit ae235b

Members

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

can_poll ()

Packit ae235b

Checks if the GPollableInputStream instance is actually pollable

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

is_readable ()

Packit ae235b

Checks if the stream is readable

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

create_source ()

Packit ae235b

Creates a GSource to poll the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

read_nonblocking ()

Packit ae235b

Does a non-blocking read or returns

Packit ae235b
G_IO_ERROR_WOULD_BLOCK

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.28

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

See Also

Packit ae235b

GInputStream, GPollableOutputStream, GFileDescriptorBased

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>