0xAX
0xAX

Reputation: 21837

Manual of glib and multithreading

Is anywhere book or good manual, but better book about GTK+/glib, and multithreading in C/GTK+? I need to run a function in another thread than main window, and make it cancellable.

Upvotes: 0

Views: 490

Answers (2)

unwind
unwind

Reputation: 400009

GCancellable is part of the GIO I/O library. It provides a thread-safe way to simply send a "cancel yourself" message, and should be easy to implement in a thread of your own.

Simply create an instance of GCancellable using g_cancelablle_new(), and then either poll it periodically (using g_cancellable_is_cancelled()) in your thread, or use the signal support.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799150

Not recommended. glib uses an event loop, so do your processing in slices via g_timeout_*() or g_idle_*(), and just stop processing when you want to cancel it.

Upvotes: 0

Related Questions