Using GCancellable



Hello:

I'm using a GCancellable to be able to cancel a reading process, but
it's behaviour is not the one I was expecting. I have this code:
  
  cancellable = g_cancellable_new ();
  file = g_file_new_for_path (path);
  input_stream = g_file_read (file, cancellable, &error);

  g_input_stream_read (G_INPUT_STREAM (input_stream),
                       buffer,
                       BUFSIZ,
                       cancellable, &error);

  g_object_unref (input_stream);
  g_object_unref (file);
  g_object_unref (cancellable);

And in another thread the cancelling call:

  g_cancellable_cancel (cancellable);

The behaviour I was expecting was that the blocking call
g_input_stream_read would be unblocked and would return after calling to
g_cancellable_cancel.

Actually it waits for g_input_stream_read to finish, so it doesn't
really cancel, but g_cancellable is marked as cancelled after that.

Is this it's normal behaviour ?
If it is, what can I do to cancel a reading process ?

Thank you,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]