Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GTK2: g_thread_init deprecated

This is my first attempt at making a threaded piece of software. It's gonna be GTK2 based on Arch Linux.

I followed the example from here:

Threaded animation with Cairo

Using the example with SIGALRM at the bottom.

I get the following warning when I compile:

warning: 'g_thread_init' is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:260) [-Wdeprecated-declarations]
if (!g_thread_supported ()){ g_thread_init(NULL); }

I'm trying to find information on how I'm supposed to go about this. The only things that come up online with this warning is bug reports of software throwing the same error when it compiles. Lots of the report seem like they say to just remove the line.

Do I just remove that line and keep the rest intact? Or is there a better way to go about this?

I am making a infotainment system to be ran on Raspberry Pi Model B with a touch screen and I wanna make sure it feels snappy like an iPhone hence why I wanna run the graphics and user input stuff in a high priority thread.

If anyone could point me in the right direction for this type of stuff, it would be greatly appreciated. Any piece of online literature would help as well as books on the subject if necessary.

Thanks in advance.

like image 892
ReX357 Avatar asked Dec 20 '13 20:12

ReX357


1 Answers

According to:

https://developer.gnome.org/glib/2.34/glib-Deprecated-Thread-APIs.html#g-thread-init

g_thread_init has been deprecated since version 2.32 and should not be used in newly-written code. This function is no longer necessary. The GLib threading system is automatically initialized at the start of your program.

The function prototype is as follows:

void g_thread_init (gpointer vtable);

This is also mentioned at the above link:

Since version 2.32, GLib does not support custom thread implementations anymore and the vtable parameter is ignored and you should pass NULL.

It's strange that in one statement they say that you should not use it and then in another say if you do use it, pass NULL as it's argument. Either way, if you're using Glib >= 2.32, calling it is no longer necessary.

like image 197
Fiddling Bits Avatar answered Nov 12 '22 21:11

Fiddling Bits