<GPollableOutputStream> is
implemented by <GOutputStream>s that can be
polled for readiness to write. 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
<GPollableOutputStream> but have only
certain instances of that class be pollable. If
pollable-output-stream:can-poll? returns false, then the
behavior of other
<GPollableOutputStream> methods is
undefined.
Checks if self is actually pollable. Some classes may implement
<GPollableOutputStream> but have only
certain instances of that class be pollable. If this method returns
#f, then the behavior of other
<GPollableOutputStream> 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 <GPollableOutputStream>.
Returned: a boolean.
#t if self is pollable, #f if not.
Creates a <GSource> that triggers when
self can be written, or cancellable is triggered or an error
occurs. The callback on the source is of the
GPollableSourceFunc type.
As with pollable-output-stream:is-writable?, it is possible that
the stream may not actually be writable even after the source triggers,
so you should use pollable-output-stream:write-nonblocking rather
than output-stream:write from the
callback.
The behaviour of this method is undefined if
pollable-output-stream:can-poll? returns #f for
self.
Passed: a <GPollableOutputStream>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable>, or #f
Returned: a <GSource>.
a new <GSource>
Checks if self can be written.
Note that some stream types may not be able to implement this 100%
reliably, and it is possible that a call to output-stream:write after this returns #t would still
block. To guarantee non-blocking behavior, you should always use
pollable-output-stream:write-nonblocking, which
will return a would-block error rather than
blocking.
The behaviour of this method is undefined if
pollable-output-stream:can-poll? returns #f for
self.
Passed: a <GPollableOutputStream>.
Returned: a boolean.
#t if self is writable, #f if not. If an error has
occurred on self, this will result in
pollable-output-stream:is-writable? returning #t,
and the next attempt to write will return the error.
Attempts to write up to count bytes from buffer to
self, as with output-stream:write. If self is not currently writable,
this will immediately return would-block, and
you can use pollable-output-stream:create-source to create a
<GSource> that will be triggered when
self is writable.
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.
Also note that if would-block is returned some
underlying transports like D/TLS require that you re-send the same
buffer and count in the next write call.
The behaviour of this method is undefined if
pollable-output-stream:can-poll? returns #f for
self.
Passed: a <GPollableOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit integer.
a buffer to write data from
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable>, or #f
Returned: a 64-bit integer.
the number of bytes written, or -1 on error (including
would-block).
Not passed: guile-gi gives the length of buffer.
the number of bytes you want to write
Checks if self is actually pollable. Some classes may implement
<GPollableOutputStream> but have only
certain instances of that class be pollable. If this method returns
#f, then the behavior of other
<GPollableOutputStream> 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
<GPollableOutputStream>, or its GType
number.
Passed: a <GPollableOutputStream>.
Returned: a boolean.
#t if self is pollable, #f if not.
Creates a <GSource> that triggers when
self can be written, or cancellable is triggered or an error
occurs. The callback on the source is of the
GPollableSourceFunc type.
As with pollable-output-stream:is-writable?, it is possible that
the stream may not actually be writable even after the source triggers,
so you should use pollable-output-stream:write-nonblocking rather
than output-stream:write from the
callback.
The behaviour of this method is undefined if
pollable-output-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
<GPollableOutputStream>, or its GType
number.
Passed: a <GPollableOutputStream>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable>, or #f
Returned: a <GSource>.
a new <GSource>
Checks if self can be written.
Note that some stream types may not be able to implement this 100%
reliably, and it is possible that a call to output-stream:write after this returns #t would still
block. To guarantee non-blocking behavior, you should always use
pollable-output-stream:write-nonblocking, which
will return a would-block error rather than
blocking.
The behaviour of this method is undefined if
pollable-output-stream:can-poll? returns #f for
self.
To override it in a new class, give register-type #:vfuncs
`((is-writable . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GPollableOutputStream>, or its GType
number.
Passed: a <GPollableOutputStream>.
Returned: a boolean.
#t if self is writable, #f if not. If an error has
occurred on self, this will result in
pollable-output-stream:is-writable? returning #t,
and the next attempt to write will return the error.
Attempts to write up to count bytes from buffer to
self, as with output-stream:write. If self is not currently writable,
this will immediately return would-block, and
you can use pollable-output-stream:create-source to create a
<GSource> that will be triggered when
self is writable.
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.
Also note that if would-block is returned some
underlying transports like D/TLS require that you re-send the same
buffer and count in the next write call.
The behaviour of this method is undefined if
pollable-output-stream:can-poll? returns #f for
self.
To override it in a new class, give register-type #:vfuncs
`((write-nonblocking . ,procedure)). The procedure is called as
(procedure self buffer) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GPollableOutputStream>, or its GType
number.
Passed: a <GPollableOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit
integer, or #f.
a buffer to write data from
Returned: a 64-bit integer.
the number of bytes written, or -1 on error (including
would-block).
Not passed: guile-gi gives the length of buffer.
the number of bytes you want to write