PollableInputStream.createSource

glib.source.Source createSource(gio.cancellable.Cancellable cancellable = null)

Creates a #GSource that triggers when stream can be read, or cancellable is triggered or an error occurs. The callback on the source is of the #GPollableSourceFunc type.

As with [gio.pollable_input_stream.PollableInputStream.isReadable], it is possible that the stream may not actually be readable even after the source triggers, so you should use [gio.pollable_input_stream.PollableInputStream.readNonblocking] rather than [gio.input_stream.InputStream.read] from the callback.

The behaviour of this method is undefined if [gio.pollable_input_stream.PollableInputStream.canPoll] returns false for stream.

Parameters

cancellablea #GCancellable, or null

Returns

a new #GSource