Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
PollableOutputStream
is implemented by GOutputStreams
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.
Since: 2.28
Synopsis
- newtype PollableOutputStream = PollableOutputStream (ManagedPtr PollableOutputStream)
- class (GObject o, IsDescendantOf PollableOutputStream o) => IsPollableOutputStream o
- toPollableOutputStream :: (MonadIO m, IsPollableOutputStream o) => o -> m PollableOutputStream
- pollableOutputStreamCanPoll :: (HasCallStack, MonadIO m, IsPollableOutputStream a) => a -> m Bool
- pollableOutputStreamCreateSource :: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) => a -> Maybe b -> m Source
- pollableOutputStreamIsWritable :: (HasCallStack, MonadIO m, IsPollableOutputStream a) => a -> m Bool
- pollableOutputStreamWriteNonblocking :: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) => a -> Maybe ByteString -> Maybe b -> m Int64
- pollableOutputStreamWritevNonblocking :: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) => a -> [OutputVector] -> Maybe b -> m (PollableReturn, Word64)
Exported types
newtype PollableOutputStream Source #
Memory-managed wrapper type.
Instances
Eq PollableOutputStream Source # | |
Defined in GI.Gio.Interfaces.PollableOutputStream (==) :: PollableOutputStream -> PollableOutputStream -> Bool # (/=) :: PollableOutputStream -> PollableOutputStream -> Bool # | |
GObject PollableOutputStream Source # | |
Defined in GI.Gio.Interfaces.PollableOutputStream | |
ManagedPtrNewtype PollableOutputStream Source # | |
TypedObject PollableOutputStream Source # | |
Defined in GI.Gio.Interfaces.PollableOutputStream | |
HasParentTypes PollableOutputStream Source # | |
Defined in GI.Gio.Interfaces.PollableOutputStream | |
IsGValue (Maybe PollableOutputStream) Source # | Convert |
Defined in GI.Gio.Interfaces.PollableOutputStream gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe PollableOutputStream -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe PollableOutputStream) # | |
type ParentTypes PollableOutputStream Source # | |
Defined in GI.Gio.Interfaces.PollableOutputStream |
class (GObject o, IsDescendantOf PollableOutputStream o) => IsPollableOutputStream o Source #
Type class for types which can be safely cast to PollableOutputStream
, for instance with toPollableOutputStream
.
Instances
(GObject o, IsDescendantOf PollableOutputStream o) => IsPollableOutputStream o Source # | |
Defined in GI.Gio.Interfaces.PollableOutputStream |
toPollableOutputStream :: (MonadIO m, IsPollableOutputStream o) => o -> m PollableOutputStream Source #
Cast to PollableOutputStream
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, canPoll, clearPending, close, closeAsync, closeFinish, createSource, flush, flushAsync, flushFinish, forceFloating, freezeNotify, getv, hasPending, isClosed, isClosing, isFloating, isWritable, notify, notifyByPspec, ref, refSink, runDispose, splice, spliceAsync, spliceFinish, stealData, stealQdata, thawNotify, unref, watchClosure, write, writeAll, writeAllAsync, writeAllFinish, writeAsync, writeBytes, writeBytesAsync, writeBytesFinish, writeFinish, writeNonblocking, writev, writevAll, writevAllAsync, writevAllFinish, writevAsync, writevFinish, writevNonblocking.
Getters
getData, getProperty, getQdata.
Setters
canPoll
pollableOutputStreamCanPoll Source #
:: (HasCallStack, MonadIO m, IsPollableOutputStream a) | |
=> a |
|
-> m Bool |
Checks if stream
is actually pollable. Some classes may implement
PollableOutputStream
but have only certain instances of that
class be pollable. If this method returns False
, then the behavior
of other PollableOutputStream
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.
Since: 2.28
createSource
pollableOutputStreamCreateSource Source #
:: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Source | Returns: a new |
Creates a Source
that triggers when stream
can be written, or
cancellable
is triggered or an error occurs. The callback on the
source is of the PollableSourceFunc
type.
As with pollableOutputStreamIsWritable
, it is possible that
the stream may not actually be writable even after the source
triggers, so you should use pollableOutputStreamWriteNonblocking
rather than outputStreamWrite
from the callback.
Since: 2.28
isWritable
pollableOutputStreamIsWritable Source #
:: (HasCallStack, MonadIO m, IsPollableOutputStream a) | |
=> a |
|
-> m Bool | Returns: |
Checks if stream
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 outputStreamWrite
after this returns True
would still block. To guarantee
non-blocking behavior, you should always use
pollableOutputStreamWriteNonblocking
, which will return a
IOErrorEnumWouldBlock
error rather than blocking.
Since: 2.28
writeNonblocking
pollableOutputStreamWriteNonblocking Source #
:: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) | |
=> a |
|
-> Maybe ByteString |
|
-> Maybe b |
|
-> m Int64 | Returns: the number of bytes written, or -1 on error (including
|
Attempts to write up to count
bytes from buffer
to stream
, as
with outputStreamWrite
. If stream
is not currently writable,
this will immediately return IOErrorEnumWouldBlock
, and you can
use pollableOutputStreamCreateSource
to create a Source
that will be triggered when stream
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 IOErrorEnumWouldBlock
is returned some underlying
transports like D/TLS require that you re-send the same buffer
and
count
in the next write call.
writevNonblocking
pollableOutputStreamWritevNonblocking Source #
:: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) | |
=> a |
|
-> [OutputVector] |
|
-> Maybe b |
|
-> m (PollableReturn, Word64) | Returns: % |
Attempts to write the bytes contained in the nVectors
vectors
to stream
,
as with outputStreamWritev
. If stream
is not currently writable,
this will immediately return %gPOLLABLERETURNWOULDBLOCK
, and you can
use pollableOutputStreamCreateSource
to create a Source
that will be triggered when stream
is writable. error
will *not* be
set in that case.
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 PollableReturnWouldBlock
is returned some underlying
transports like D/TLS require that you re-send the same vectors
and
nVectors
in the next write call.
Since: 2.60