Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
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.
- newtype PollableOutputStream = PollableOutputStream (ManagedPtr PollableOutputStream)
- noPollableOutputStream :: Maybe PollableOutputStream
- class GObject o => IsPollableOutputStream o
- toPollableOutputStream :: IsPollableOutputStream o => o -> IO PollableOutputStream
- data PollableOutputStreamCanPollMethodInfo
- pollableOutputStreamCanPoll :: (HasCallStack, MonadIO m, IsPollableOutputStream a) => a -> m Bool
- data PollableOutputStreamCreateSourceMethodInfo
- pollableOutputStreamCreateSource :: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) => a -> Maybe b -> m Source
- data PollableOutputStreamIsWritableMethodInfo
- pollableOutputStreamIsWritable :: (HasCallStack, MonadIO m, IsPollableOutputStream a) => a -> m Bool
- data PollableOutputStreamWriteNonblockingMethodInfo
- pollableOutputStreamWriteNonblocking :: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) => a -> Maybe ByteString -> Maybe b -> m Int64
Exported types
newtype PollableOutputStream Source #
GObject PollableOutputStream Source # | |
IsObject PollableOutputStream Source # | |
IsOutputStream PollableOutputStream Source # | |
IsPollableOutputStream PollableOutputStream Source # | |
((~) * info (ResolvePollableOutputStreamMethod t PollableOutputStream), MethodInfo * info PollableOutputStream p) => IsLabel t (PollableOutputStream -> p) Source # | |
((~) * info (ResolvePollableOutputStreamMethod t PollableOutputStream), MethodInfo * info PollableOutputStream p) => IsLabelProxy t (PollableOutputStream -> p) Source # | |
HasAttributeList * PollableOutputStream Source # | |
type AttributeList PollableOutputStream Source # | |
type SignalList PollableOutputStream Source # | |
class GObject o => IsPollableOutputStream o Source #
Methods
canPoll
data PollableOutputStreamCanPollMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsPollableOutputStream a) => MethodInfo * PollableOutputStreamCanPollMethodInfo a signature Source # | |
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
data PollableOutputStreamCreateSourceMethodInfo Source #
((~) * signature (Maybe b -> m Source), MonadIO m, IsPollableOutputStream a, IsCancellable b) => MethodInfo * PollableOutputStreamCreateSourceMethodInfo a signature Source # | |
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
data PollableOutputStreamIsWritableMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsPollableOutputStream a) => MethodInfo * PollableOutputStreamIsWritableMethodInfo a signature Source # | |
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
data PollableOutputStreamWriteNonblockingMethodInfo Source #
((~) * signature (Maybe ByteString -> Maybe b -> m Int64), MonadIO m, IsPollableOutputStream a, IsCancellable b) => MethodInfo * PollableOutputStreamWriteNonblockingMethodInfo a signature Source # | |
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.