开发者

Manual of glib and multithreading

开发者 https://www.devze.com 2023-01-04 05:56 出处:网络
Is anywhere book or g开发者_Go百科ood 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.GCance

Is anywhere book or g开发者_Go百科ood 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号