PollableInputStream.readNonblocking

ptrdiff_t readNonblocking(ref ubyte[] buffer, gio.cancellable.Cancellable cancellable = null)

Attempts to read up to count bytes from stream into buffer, as with gio.input_stream.InputStream.read. If stream is not currently readable, this will immediately return gio.types.IOErrorEnum.WouldBlock, and you can use gio.pollable_input_stream.PollableInputStream.createSource to create a #GSource that will be triggered when stream 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 gio.pollable_input_stream.PollableInputStream.canPoll returns false for stream.

Parameters

buffera buffer to read data into (which should be at least count bytes long).
cancellablea #GCancellable, or null

Returns

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

gio.types.IOErrorEnum.WouldBlock).

Throws