RFC: Listening for devices being added - udev vs. X11

Matthew Brush mbrush at codebrainz.ca
Fri Apr 25 02:43:05 CEST 2014


On 14-04-22 08:35 PM, Martin Kelly wrote:
>>
>> Technically all code is throw-away code from that perspective (except
>> maybe win32 API code), even as an example with GTK4 planned, writing
>> GTK3 code is already not future-proof as it will be deprecated closer to
>> GTK4 (much of it already is). That being said, I'd wager X(lib) will
>> still be available in one form or another for far longer than GTK3, GTK4
>> and Udev combined :)
>>
>> Note: I have no opinion on whether patches should be accepted, other
>> than maybe to ask why Gudev over libudev directly since it's quite easy
>> and provides a "GLIB-like" API already without an additional (small)
>> depenency.
>>
>
> Seeing as I just wrote a pure udev version of the patch followed by a
> gudev version, the reason for gudev is that it abstracts for you a
> number of the details you'd normally have to deal with when using udev
> directly. For example, to listen for udev events, you would need to fork
> a listener thread, which means you'd have to handle memory management,
> thread exit, zombie collection, etc. With gudev, you just register a
> callback and all the threading is taken care of for you. In addition,
> gudev gives you a nicer uevent object to work with, which is easier to
> query and requires fewer lines of code to get the right info out of it.
>

It was a while ago I used libudev but I thought it gave you a file 
descriptor you could watch/poll for events "asynchronously" without 
using threads (ex. `g_io_create_watch()`).

Anyway was just curious, thanks for responding.

Cheers,
Matthew Brush



More information about the Xfce4-dev mailing list