Gio.File and thread-safety

Hi,

GLib doc recommends to duplicate Gio.Files when using them from another thread.

Is it necessary for APIs that don’t do I/O, like Gio.File.get_relative_path?

1 Like

Yes, it is necessary, because those APIs may access private members of the GFile without locking. It’s more about that (for any of the GFile methods) than about being thread-safe with I/O. Being thread-safe with I/O is only one part of concurrency safety with I/O, because as well as other threads you have to interact concurrently with other processes.

2 Likes

Perfect, thank you!!

1 Like