<GPollableInputStream> is implemented
by <GInputStream>s that can be polled for
readiness to read. This can be used when interfacing with a non-GIO API
that expects UNIX-file-descriptor-style asynchronous I/O rather than
GIO-style.
Some classes may implement
<GPollableInputStream> but have only
certain instances of that class be pollable. If
pollable-input-stream:can-poll? returns false, then the
behavior of other
<GPollableInputStream> methods is
undefined.
Checks if self is actually pollable. Some classes may implement
<GPollableInputStream> but have only
certain instances of that class be pollable. If this method returns
#f, then the behavior of other
<GPollableInputStream> methods is
undefined.
For any given stream, the value returned by this method is constant; a stream cannot switch from pollable to non-pollable or vice versa.
Passed: a <GPollableInputStream>.
Returned: a boolean.
#t if self is pollable, #f if not.
Creates a <GSource> that triggers when
self can be read, or cancellable is triggered or an error
occurs. The callback on the source is of the
GPollableSourceFunc type.
As with pollable-input-stream:is-readable?, it is possible that
the stream may not actually be readable even after the source triggers,
so you should use pollable-input-stream:read-nonblocking! rather than
input-stream:read! from the callback.
The behaviour of this method is undefined if
pollable-input-stream:can-poll? returns #f for
self.
Passed: a <GPollableInputStream>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable>, or #f
Returned: a <GSource>.
a new <GSource>
Checks if self can be read.
Note that some stream types may not be able to implement this 100%
reliably, and it is possible that a call to input-stream:read! after this returns #t would still
block. To guarantee non-blocking behavior, you should always use
pollable-input-stream:read-nonblocking!, which will
return a would-block error rather than
blocking.
The behaviour of this method is undefined if
pollable-input-stream:can-poll? returns #f for
self.
Passed: a <GPollableInputStream>.
Returned: a boolean.
#t if self is readable, #f if not. If an error has
occurred on self, this will result in
pollable-input-stream:is-readable? returning #t,
and the next attempt to read will return the error.
Attempts to read up to count bytes from self into
buffer, as with input-stream:read!.
If self is not currently readable, this will immediately return
would-block, and you can use
pollable-input-stream:create-source to create a
<GSource> that will be triggered when
self is readable.
Note that since this method never blocks, you cannot actually use cancellable to cancel it. However, it will return an error if cancellable has already been cancelled when you call, which may happen if you call this method after a source triggers due to having been cancelled.
The behaviour of this method is undefined if
pollable-input-stream:can-poll? returns #f for
self.
Passed: a <GPollableInputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit integer. It is filled in, and returned: a bytevector.
a buffer to read data into (which should be at least count bytes long).
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable>, or #f
Returned: a 64-bit integer.
the number of bytes read, or -1 on error (including
would-block).
Not returned: it is the length of buffer.
the number of bytes you want to read
Checks if self is actually pollable. Some classes may implement
<GPollableInputStream> but have only
certain instances of that class be pollable. If this method returns
#f, then the behavior of other
<GPollableInputStream> methods is
undefined.
For any given stream, the value returned by this method is constant; a stream cannot switch from pollable to non-pollable or vice versa.
To override it in a new class, give register-type #:vfuncs
`((can-poll . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GPollableInputStream>, or its GType
number.
Passed: a <GPollableInputStream>.
Returned: a boolean.
#t if self is pollable, #f if not.
Creates a <GSource> that triggers when
self can be read, or cancellable is triggered or an error
occurs. The callback on the source is of the
GPollableSourceFunc type.
As with pollable-input-stream:is-readable?, it is possible that
the stream may not actually be readable even after the source triggers,
so you should use pollable-input-stream:read-nonblocking! rather than
input-stream:read! from the callback.
The behaviour of this method is undefined if
pollable-input-stream:can-poll? returns #f for
self.
To override it in a new class, give register-type #:vfuncs
`((create-source . ,procedure)). The procedure is called as
(procedure self cancellable) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GPollableInputStream>, or its GType
number.
Passed: a <GPollableInputStream>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable>, or #f
Returned: a <GSource>.
a new <GSource>
Checks if self can be read.
Note that some stream types may not be able to implement this 100%
reliably, and it is possible that a call to input-stream:read! after this returns #t would still
block. To guarantee non-blocking behavior, you should always use
pollable-input-stream:read-nonblocking!, which will
return a would-block error rather than
blocking.
The behaviour of this method is undefined if
pollable-input-stream:can-poll? returns #f for
self.
To override it in a new class, give register-type #:vfuncs
`((is-readable . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GPollableInputStream>, or its GType
number.
Passed: a <GPollableInputStream>.
Returned: a boolean.
#t if self is readable, #f if not. If an error has
occurred on self, this will result in
pollable-input-stream:is-readable? returning #t,
and the next attempt to read will return the error.
Attempts to read up to count bytes from self into
buffer, as with input-stream:read!.
If self is not currently readable, this will immediately return
would-block, and you can use
pollable-input-stream:create-source to create a
<GSource> that will be triggered when
self is readable.
Note that since this method never blocks, you cannot actually use cancellable to cancel it. However, it will return an error if cancellable has already been cancelled when you call, which may happen if you call this method after a source triggers due to having been cancelled.
The behaviour of this method is undefined if
pollable-input-stream:can-poll? returns #f for
self.
To override it in a new class, give register-type #:vfuncs
`((read-nonblocking . ,procedure)). The procedure is called as
(procedure self buffer) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GPollableInputStream>, or its GType
number.
Passed: a <GPollableInputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit
integer, or #f. It is filled in, and returned: a bytevector, or
#f.
a buffer to read data into (which should be at least count bytes long).
Returned: a 64-bit integer.
the number of bytes read, or -1 on error (including
would-block).
Not returned: it is the length of buffer.
the number of bytes you want to read