Should `MonitorSocket` be marked Send?
d0u9 opened this issue · 5 comments
The underlaying *mut ffi::udev
, *mut ffi::udev_monitor
pointers should be safe to be sent between threads. But, by default, rust marks struct contained raw pointers are !Send
, and it makes life harder in multhreading programming env.
That depends on the udev implementation. I think systemd-udev
is indeed thread-safe, but I am not sure, if that is true for systemd-less udev implementations or the BSDs devd compatibility layer.
Well, I will take a view on systemd's source.
I close this issue temporarily.
just ran into this! I initialize everything and then simply move it to a different thread, and i do not use it from multiple threads. just transfer it to a new thread after initialization. Am i safe to make this as Send? (i could redesign the init stuff but i am just curious if it can still be marked as thread safe if i "promise" i only use it from one thread)
I have no idea. There are no docs, that guarantee this will work and as far as I know, udev could initialize thread-local storage on init. 🤷♀️
i see. well thanks for fast response. probably shouldnt be passing it around threads then. will refactor my init